get-domain-locale.js 1.3 KB

123456789101112131415161718192021222324252627282930
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", {
  3. value: true
  4. });
  5. exports.getDomainLocale = getDomainLocale;
  6. const basePath = process.env.__NEXT_ROUTER_BASEPATH || '';
  7. function getDomainLocale(path, locale, locales, domainLocales) {
  8. if (process.env.__NEXT_I18N_SUPPORT) {
  9. const normalizeLocalePath = require('./normalize-locale-path').normalizeLocalePath;
  10. const detectDomainLocale = require('./detect-domain-locale').detectDomainLocale;
  11. const target = locale || normalizeLocalePath(path, locales).detectedLocale;
  12. const domain = detectDomainLocale(domainLocales, undefined, target);
  13. if (domain) {
  14. const proto = `http${domain.http ? '' : 's'}://`;
  15. const finalLocale = target === domain.defaultLocale ? '' : `/${target}`;
  16. return `${proto}${domain.domain}${basePath}${finalLocale}${path}`;
  17. }
  18. return false;
  19. } else {
  20. return false;
  21. }
  22. }
  23. if ((typeof exports.default === 'function' || (typeof exports.default === 'object' && exports.default !== null)) && typeof exports.default.__esModule === 'undefined') {
  24. Object.defineProperty(exports.default, '__esModule', { value: true });
  25. Object.assign(exports.default, exports);
  26. module.exports = exports.default;
  27. }
  28. //# sourceMappingURL=get-domain-locale.js.map