Files
klz-cables.com/.pnpm-store/v10/files/78/f1f8dc75a71a9ac7ea60195976f998836522ec8c70f8f529a6ea468ecfd57b440fcc712d2e8a51464f7b93ee43c1e3850888aa1b5b35dd5aa5ce0a764ef827
Marc Mintel 5397309103
Some checks failed
Build & Deploy / 🔍 Prepare (push) Successful in 20s
Build & Deploy / 🧪 QA (push) Failing after 34s
Build & Deploy / 🏗️ Build (push) Has started running
Build & Deploy / 🚀 Deploy (push) Has been cancelled
Build & Deploy / 🧪 Smoke Test (push) Has been cancelled
Build & Deploy / ⚡ Lighthouse (push) Has been cancelled
Build & Deploy / 🔔 Notify (push) Has been cancelled
fix(products): fix breadcrumbs and product filtering (backport from main)
2026-02-24 16:04:21 +01:00

36 lines
1.5 KiB
Plaintext

/**
* Sanitizes fallbackLocale based on a provided fallbackLocale, locale and localization config
*
* Handles the following scenarios:
* - determines if a fallback locale should be used
* - determines if a locale specific fallback should be used in place of the default locale
* - sets the fallbackLocale to 'null' if no fallback locale should be used
*/ export const sanitizeFallbackLocale = ({ fallbackLocale, locale, localization })=>{
if (fallbackLocale === undefined || fallbackLocale === null) {
if (localization && localization.fallback) {
// Check for locale specific fallback
const localeSpecificFallback = localization.locales.length ? localization.locales.find((localeConfig)=>localeConfig.code === locale)?.fallbackLocale : undefined;
if (localeSpecificFallback) {
return localeSpecificFallback;
}
return localization.defaultLocale;
}
return false;
} else if (Array.isArray(fallbackLocale)) {
return fallbackLocale.filter((localeCode)=>localization.localeCodes.includes(localeCode));
} else if (fallbackLocale) {
if ([
'false',
'none',
'null'
].includes(fallbackLocale)) {
return false;
}
if (localization.localeCodes.includes(fallbackLocale)) {
return fallbackLocale;
}
}
return false;
};
//# sourceMappingURL=sanitizeFallbackLocale.js.map