Skip to content

The Open Source DocuSign Alternative.

fix: add check for invalid locales (#1353)

David Nguyenc043fa9c06ea
diff --git a/packages/lib/utils/i18n.ts b/packages/lib/utils/i18n.ts
index 01bf82a3f..6f3748066 100644
--- a/packages/lib/utils/i18n.ts
+++ b/packages/lib/utils/i18n.ts
@@ -90,8 +90,18 @@ export const extractLocaleData = ({
lang = 'en';
}
+ // Filter out locales that are not valid.
+ const locales = (langHeader?.locales ?? []).filter((locale) => {
+ try {
+ new Intl.Locale(locale);
+ return true;
+ } catch {
+ return false;
+ }
+ });
+
return {
lang: lang || APP_I18N_OPTIONS.sourceLang,
- locales: langHeader.locales,
+ locales,
};
};