@synergy-design-system/components
Version:
This package provides the base of the Synergy Design System as native web components. It uses [lit](https://www.lit.dev) and parts of [shoelace](https://shoelace.style/). Synergy officially supports the latest two versions of all major browsers (as define
31 lines (29 loc) • 933 B
JavaScript
// 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-synergy"));
if (configScript) {
setBasePath(configScript.getAttribute("data-synergy"));
} else {
const fallbackScript = scripts.find((s) => {
return /synergy(\.min)?\.js($|\?)/.test(s.src) || /synergy-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
};
//# sourceMappingURL=chunk.234ERFCE.js.map