sudovanilla-website/public/@shoelace-style/shoelace/cdn/chunks/chunk.3Y6SB6QS.js

30 lines
894 B
JavaScript
Raw Normal View History

2024-05-13 22:34:06 -05:00
// src/utilities/base-path.ts
var basePath = "";
function setBasePath(path) {
basePath = path;
}
function getBasePath(subpath = "") {
if (!basePath) {
const scripts = [...document.getElementsByTagName("script")];
const configScript = scripts.find((script) => script.hasAttribute("data-shoelace"));
if (configScript) {
setBasePath(configScript.getAttribute("data-shoelace"));
} else {
const fallbackScript = scripts.find((s) => {
return /shoelace(\.min)?\.js($|\?)/.test(s.src) || /shoelace-autoloader(\.min)?\.js($|\?)/.test(s.src);
});
let path = "";
if (fallbackScript) {
path = fallbackScript.getAttribute("src");
}
setBasePath(path.split("/").slice(0, -1).join("/"));
}
}
return basePath.replace(/\/$/, "") + (subpath ? `/${subpath.replace(/^\//, "")}` : ``);
}
export {
setBasePath,
getBasePath
};