UNPKG

1.85 kBSource Map (JSON)View Raw
1{"version":3,"sources":["../../../../next-server/lib/i18n/detect-domain-locale.ts"],"names":["detectDomainLocale","domainItems","hostname","detectedLocale","domainItem","toLowerCase","item","domainHostname","domain","split","defaultLocale","locales","some","locale"],"mappings":"mFAAO,QAASA,CAAAA,kBAAT,CACLC,WADK,CASLC,QATK,CAULC,cAVK,CAWL,CACA,GAAIC,CAAAA,UAAJ,CASA,GAAIH,WAAJ,CAAiB,CACf,GAAIE,cAAJ,CAAoB,CAClBA,cAAc,CAAGA,cAAc,CAACE,WAAf,EAAjB,CACD,CAED,IAAK,KAAMC,CAAAA,IAAX,GAAmBL,CAAAA,WAAnB,CAAgC,gCAC9B;AACA,KAAMM,CAAAA,cAAc,eAAGD,IAAI,CAACE,MAAR,eAAG,aAAaC,KAAb,CAAmB,GAAnB,EAAwB,CAAxB,EAA2BJ,WAA3B,EAAvB,CACA,GACEH,QAAQ,GAAKK,cAAb,EACAJ,cAAc,GAAKG,IAAI,CAACI,aAAL,CAAmBL,WAAnB,EADnB,iBAEAC,IAAI,CAACK,OAFL,SAEA,cAAcC,IAAd,CAAoBC,MAAD,EAAYA,MAAM,CAACR,WAAP,KAAyBF,cAAxD,CAHF,CAIE,CACAC,UAAU,CAAGE,IAAb,CACA,MACD,CACF,CACF,CAED,MAAOF,CAAAA,UAAP,CACD","sourcesContent":["export function detectDomainLocale(\n domainItems:\n | Array<{\n http?: boolean\n domain: string\n locales?: string[]\n defaultLocale: string\n }>\n | undefined,\n hostname?: string,\n detectedLocale?: string\n) {\n let domainItem:\n | {\n http?: boolean\n domain: string\n locales?: string[]\n defaultLocale: string\n }\n | undefined\n\n if (domainItems) {\n if (detectedLocale) {\n detectedLocale = detectedLocale.toLowerCase()\n }\n\n for (const item of domainItems) {\n // remove port if present\n const domainHostname = item.domain?.split(':')[0].toLowerCase()\n if (\n hostname === domainHostname ||\n detectedLocale === item.defaultLocale.toLowerCase() ||\n item.locales?.some((locale) => locale.toLowerCase() === detectedLocale)\n ) {\n domainItem = item\n break\n }\n }\n }\n\n return domainItem\n}\n"]}
\No newline at end of file