detect-domain-locale.js 925 B

12345678910111213141516171819202122232425
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", {
  3. value: true
  4. });
  5. exports.detectDomainLocale = detectDomainLocale;
  6. function detectDomainLocale(domainItems, hostname, detectedLocale) {
  7. let domainItem;
  8. if (domainItems) {
  9. if (detectedLocale) {
  10. detectedLocale = detectedLocale.toLowerCase();
  11. }
  12. for (const item of domainItems){
  13. var ref, ref1;
  14. // remove port if present
  15. const domainHostname = (ref = item.domain) == null ? void 0 : ref.split(':')[0].toLowerCase();
  16. if (hostname === domainHostname || detectedLocale === item.defaultLocale.toLowerCase() || ((ref1 = item.locales) == null ? void 0 : ref1.some((locale)=>locale.toLowerCase() === detectedLocale))) {
  17. domainItem = item;
  18. break;
  19. }
  20. }
  21. }
  22. return domainItem;
  23. }
  24. //# sourceMappingURL=detect-domain-locale.js.map