IOweb/node_modules/astro/dist/i18n/path.js
2026-07-03 15:07:38 -05:00

26 lines
676 B
JavaScript

function pathHasLocale(path, locales) {
const segments = path.split("/").map(normalizeThePath);
for (const segment of segments) {
for (const locale of locales) {
if (typeof locale === "string") {
if (normalizeTheLocale(segment) === normalizeTheLocale(locale)) {
return true;
}
} else if (segment === locale.path) {
return true;
}
}
}
return false;
}
function normalizeTheLocale(locale) {
return locale.replaceAll("_", "-").toLowerCase();
}
function normalizeThePath(path) {
return path.endsWith(".html") ? path.slice(0, -5) : path;
}
export {
normalizeTheLocale,
normalizeThePath,
pathHasLocale
};