@@ -192,29 +192,6 @@ export function getPageLocale(currentPath, locales = pageLocales) {
192192 return '' ;
193193}
194194
195- let configJson = null ;
196-
197- const cacheByBase = new Map ( ) ;
198-
199- export async function getLingoSiteMappingConfig ( fqdn = 'www.adobe.com' , baseUrl = 'https://www.adobe.com' ) {
200- const normalized = baseUrl . replace ( / \/ $ / , '' ) ;
201- const cacheKey = `${ normalized } ::${ fqdn } ` ;
202- if ( ! cacheByBase . has ( normalized ) ) {
203- const url = `${ normalized } /federal/assets/data/lingo-site-mapping.json?${ encodeURIComponent ( cacheKey ) } ` ;
204- const promise = fetch ( url )
205- . then ( ( response ) => {
206- if ( ! response . ok ) throw new Error ( `HTTP ${ response . status } ` ) ;
207- return response . json ( ) ;
208- } )
209- . catch ( ( e ) => {
210- cacheByBase . delete ( normalized ) ;
211- throw e ;
212- } ) ;
213- cacheByBase . set ( normalized , promise ) ;
214- }
215- return cacheByBase . get ( normalized ) ;
216- }
217-
218195export const isValidUuid = ( id ) => / ^ [ 0 - 9 a - f A - F ] { 8 } - [ 0 - 9 a - f A - F ] { 4 } - [ 0 - 9 a - f A - F ] { 4 } - [ 0 - 9 a - f A - F ] { 4 } - [ 0 - 9 a - f A - F ] { 12 } $ / . test ( id ) ;
219196
220197export const loadStrings = async (
@@ -569,9 +546,11 @@ const isLocaleInRegionalSites = (regionalSites, locStr) => {
569546 . includes ( locStr ) ;
570547} ;
571548
572- export async function getIsLingoLocale ( origin , country , language , fqdn = 'www.adobe.com' ) {
549+ async function getIsLingoLocale ( origin , country , language , fqdn = 'www.adobe.com' ) {
573550 if ( origin === 'news' ) return true ;
574- if ( ! configJson ) configJson = await getLingoSiteMappingConfig ( fqdn ) ;
551+ const response = await fetch ( `https://www.adobe.com/federal/assets/data/lingo-site-mapping.json?${ fqdn } ` ) ;
552+ if ( ! response . ok ) throw new Error ( `HTTP ${ response . status } ` ) ;
553+ const configJson = await response . json ( ) ;
575554
576555 let siteId ;
577556 let isKnownLingoSiteLocale = false ;
@@ -624,16 +603,13 @@ async function getLangFirstParam(origin, country, language) {
624603 return true ;
625604}
626605
627- async function getLingoSiteLocale ( origin , path , fqdn = 'www.adobe.com' , fromBulkPublisher = false ) {
606+ async function getLingoSiteLocale ( origin , path , fqdn = 'www.adobe.com' ) {
628607 const host = origin . toLowerCase ( ) ;
629- let lingoSiteMapping ;
630- // only provide fallback values if not from the bulk publisher
631- if ( ! fromBulkPublisher ) {
632- lingoSiteMapping = {
633- country : 'xx' ,
634- language : 'en' ,
635- } ;
636- }
608+ let lingoSiteMapping = {
609+ country : 'xx' ,
610+ language : 'en' ,
611+ } ;
612+
637613 // Extract pathname from URL if path includes domain
638614 let pathname = path ;
639615 if ( path . includes ( '://' ) || ! path . startsWith ( '/' ) ) {
@@ -653,7 +629,9 @@ async function getLingoSiteLocale(origin, path, fqdn = 'www.adobe.com', fromBulk
653629
654630 try {
655631 let siteId ;
656- if ( ! configJson ) configJson = await getLingoSiteMappingConfig ( fqdn ) ;
632+ const response = await fetch ( `https://www.adobe.com/federal/assets/data/lingo-site-mapping.json?${ fqdn } ` ) ;
633+ if ( ! response . ok ) throw new Error ( `HTTP ${ response . status } ` ) ;
634+ const configJson = await response . json ( ) ;
657635
658636 const siteQueryIndexMap = configJson [ 'site-query-index-map' ] ?. data ?? [ ] ;
659637 const siteLocalesData = configJson [ 'site-locales' ] ?. data ?? [ ] ;
@@ -708,31 +686,18 @@ async function getLingoSiteLocale(origin, path, fqdn = 'www.adobe.com', fromBulk
708686 return lingoSiteMapping ;
709687}
710688
711- export const getLanguageFirstCountryAndLang = async (
712- path ,
713- origin ,
714- fqdn ,
715- fromBulkPublisher = false ,
716- ) => {
689+ export const getLanguageFirstCountryAndLang = async ( path , origin , fqdn ) => {
717690 const localeArr = path . split ( '/' ) ;
718- let langStr ;
719- let countryStr ;
720- // only provide fallback values if not from the bulk publisher
721- if ( ! fromBulkPublisher ) {
722- langStr = 'en' ;
723- countryStr = 'xx' ;
724- }
691+ let langStr = 'en' ;
692+ let countryStr = 'xx' ;
725693 if ( origin . toLowerCase ( ) === 'news' ) {
726694 langStr = LANGS [ localeArr [ 1 ] ] ?? LANGS [ '' ] ?? 'en' ;
727695 countryStr = LOCALES [ localeArr [ 2 ] ] ?? 'xx' ;
728696 if ( typeof countryStr === 'object' ) {
729697 countryStr = countryStr . ietf ?. split ( '-' ) [ 1 ] ?? 'xx' ;
730698 }
731699 } else {
732- const mapping = await getLingoSiteLocale ( origin , path , fqdn , fromBulkPublisher ) ;
733- if ( ! mapping ) {
734- throw new Error ( 'Failed to get lingo site locale for bulk publisher' ) ;
735- }
700+ const mapping = await getLingoSiteLocale ( origin , path , fqdn ) ;
736701 countryStr = LOCALES [ mapping . country . toLowerCase ( ) ] ?? 'xx' ;
737702 if ( typeof countryStr === 'object' ) {
738703 countryStr = countryStr . ietf ?. split ( '-' ) [ 1 ] ?? 'xx' ;
0 commit comments