zephyr-agent
Version:
Zephyr plugin agent
89 lines (88 loc) • 3.19 kB
JavaScript
;
var __webpack_require__ = {};
(()=>{
__webpack_require__.d = (exports1, getters, values)=>{
var define = (defs, kind)=>{
for(var key in defs)if (__webpack_require__.o(defs, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
enumerable: true,
[kind]: defs[key]
});
};
define(getters, "get");
define(values, "value");
};
})();
(()=>{
__webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
})();
(()=>{
__webpack_require__.r = (exports1)=>{
if ("u" > typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
value: 'Module'
});
Object.defineProperty(exports1, '__esModule', {
value: true
});
};
})();
var __webpack_exports__ = {};
__webpack_require__.r(__webpack_exports__);
function normalizeBasePath(baseHref) {
if (!baseHref) return '';
let normalized = baseHref.trim();
if (!normalized || [
'/',
'./',
'.',
'auto'
].includes(normalized)) return '';
if (/^(?:https?:)?\/\//i.test(normalized)) try {
normalized = new URL(normalized.startsWith('//') ? `https:${normalized}` : normalized).pathname;
} catch {
return '';
}
normalized = normalized.split(/[?#]/, 1)[0]?.trim() ?? '';
const segments = normalized.replace(/^\.\//, '').split('/').map((segment)=>segment.trim()).filter((segment)=>segment && '.' !== segment);
return segments.includes('..') ? '' : segments.join('/');
}
function isAbsolutePath(path) {
return path.startsWith('/') || path.includes('://');
}
function isIndexHtml(path) {
return path.endsWith('index.html');
}
function applyBaseHrefToPath(path, normalizedBaseHref) {
if (isAbsolutePath(path) || isIndexHtml(path)) return path;
if (!normalizedBaseHref) return path;
return `${normalizedBaseHref}/${path}`;
}
function applyBaseHrefToAssets(assetsMap, baseHref) {
const normalizedBaseHref = normalizeBasePath(baseHref);
if (!normalizedBaseHref) return assetsMap;
const result = {};
Object.values(assetsMap).forEach((asset)=>{
const newAsset = {
...asset
};
newAsset.path = applyBaseHrefToPath(asset.path, normalizedBaseHref);
result[newAsset.path] = newAsset;
});
return result;
}
__webpack_require__.d(__webpack_exports__, {
applyBaseHrefToAssets: ()=>applyBaseHrefToAssets,
applyBaseHrefToPath: ()=>applyBaseHrefToPath,
normalizeBasePath: ()=>normalizeBasePath
});
exports.applyBaseHrefToAssets = __webpack_exports__.applyBaseHrefToAssets;
exports.applyBaseHrefToPath = __webpack_exports__.applyBaseHrefToPath;
exports.normalizeBasePath = __webpack_exports__.normalizeBasePath;
for(var __rspack_i in __webpack_exports__)if (-1 === [
"applyBaseHrefToAssets",
"applyBaseHrefToPath",
"normalizeBasePath"
].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
Object.defineProperty(exports, '__esModule', {
value: true
});
//# sourceMappingURL=ze-basehref-handler.js.map