Răsfoiți Sursa

fix(admin-ui): Fix bad locale detection regex

https://github.com/vendure-ecommerce/vendure/security/code-scanning/34
Michael Bromley 1 an în urmă
părinte
comite
f336d7fb68

+ 2 - 2
packages/admin-ui/src/lib/core/src/shared/pipes/locale-base.pipe.ts

@@ -38,7 +38,7 @@ export abstract class LocaleBasePipe implements OnDestroy, PipeTransform {
      * is valid for the Intl API.
      */
     protected getActiveLocale(localeOverride?: unknown): string {
-        const locale = typeof localeOverride === 'string' ? localeOverride : this.locale ?? 'en';
+        const locale = typeof localeOverride === 'string' ? localeOverride : (this.locale ?? 'en');
         const hyphenated = locale?.replace(/_/g, '-');
 
         // Check for a double-region string, containing 2 region codes like
@@ -46,7 +46,7 @@ export abstract class LocaleBasePipe implements OnDestroy, PipeTransform {
         // and the first region discarded. This would only ever be an issue for
         // those languages where the translation file itself encodes the region,
         // as in pt_BR & pt_PT.
-        const matches = hyphenated?.match(/^([a-zA-Z_-]+)(-[A-Z][A-Z])(-[A-Z][A-z])$/);
+        const matches = hyphenated?.match(/^([a-zA-Z_-]+)(-[A-Z][A-Z])(-[A-Z][A-Z])$/);
         if (matches?.length) {
             const overriddenLocale = matches[1] + matches[3];
             return overriddenLocale;