@wroud/vite-plugin-ssg
Version:
A Vite plugin for static site generation (SSG) with React. Renders React applications to static HTML for faster load times and improved SEO.
25 lines • 650 B
JavaScript
export function pathUrlWithBase(base, url) {
if (url === undefined) {
return url;
}
if (url.startsWith("/")) {
if (base?.startsWith("http")) {
return new URL(url ?? "/", base).href;
}
return url;
}
if (url?.startsWith("http")) {
if (base?.startsWith("http")) {
return url;
}
if (new URL(url).origin !== new URL(import.meta.url).origin) {
return url;
}
url = new URL(url).pathname.slice(1);
}
if (base !== undefined) {
return (base + url);
}
return url;
}
//# sourceMappingURL=pathUrlWithBase.js.map