"use strict";
const common_vendor = require("../common/vendor.js");
const settings_enums = require("../settings/enums.js");
const settings_siteSetting = require("../settings/siteSetting.js");
const utils_is = require("./is.js");
function getFileUrl(url, planB = false) {
  if (url === "")
    return url;
  if (!utils_is.isString(url))
    return url;
  if (url.indexOf("/static") === 0)
    return url;
  if (/^(https|http):\/\//i.test(url) || /^(data|http|https):/i.test(url) || url.indexOf("http://") >= 0 || url.indexOf("https://") >= 0)
    return url;
  if (!/^\//.test(url) && !planB)
    url = `/orderFood/${url}`;
  url = url.replace(/\.+\//gi, "/").replace(/~+/gi, "/").replace(/\/+/gi, "/").replace(/\//, "").replace(/\\/g, "/");
  let prefix = common_vendor.index.getStorageSync(settings_enums.CDN_CACHE_KEY) || settings_siteSetting.DEFAULT_CDN_URL;
  if (planB)
    prefix = common_vendor.index.getStorageSync("CDN_UPLOAD") || settings_siteSetting.UPLOAD;
  const systemInfo = common_vendor.index.getSystemInfoSync();
  const platform = systemInfo.platform;
  if (url.split(".")[1] == "webp" && platform == "ios") {
    if (systemInfo.osVersion.split(".")[0] < "18" || systemInfo.osVersion.split(".")[0] == "18" && systemInfo.osVersion.split(".")[1] < "2") {
      url = url.split(".")[0] + ".jpg";
    }
  }
  return prefix + url;
}
exports.getFileUrl = getFileUrl;
//# sourceMappingURL=../../.sourcemap/mp-weixin/utils/file.js.map
