website hosted
This commit is contained in:
6
node_modules/@astrojs/sitemap/dist/utils/parse-i18n-url.d.ts
generated
vendored
Normal file
6
node_modules/@astrojs/sitemap/dist/utils/parse-i18n-url.d.ts
generated
vendored
Normal file
@@ -0,0 +1,6 @@
|
||||
interface ParsedI18nUrl {
|
||||
locale: string;
|
||||
path: string;
|
||||
}
|
||||
export declare function parseI18nUrl(url: string, defaultLocale: string, locales: Record<string, string>, base: string): ParsedI18nUrl | undefined;
|
||||
export {};
|
||||
24
node_modules/@astrojs/sitemap/dist/utils/parse-i18n-url.js
generated
vendored
Normal file
24
node_modules/@astrojs/sitemap/dist/utils/parse-i18n-url.js
generated
vendored
Normal file
@@ -0,0 +1,24 @@
|
||||
function parseI18nUrl(url, defaultLocale, locales, base) {
|
||||
if (!url.startsWith(base)) {
|
||||
return void 0;
|
||||
}
|
||||
let s = url.slice(base.length);
|
||||
if (!s || s === "/") {
|
||||
return { locale: defaultLocale, path: "/" };
|
||||
}
|
||||
if (s[0] !== "/") {
|
||||
s = "/" + s;
|
||||
}
|
||||
const locale = s.split("/")[1];
|
||||
if (locale in locales) {
|
||||
let path = s.slice(1 + locale.length);
|
||||
if (!path) {
|
||||
path = "/";
|
||||
}
|
||||
return { locale, path };
|
||||
}
|
||||
return { locale: defaultLocale, path: s };
|
||||
}
|
||||
export {
|
||||
parseI18nUrl
|
||||
};
|
||||
Reference in New Issue
Block a user