/opt/canhelp/node_modules/next/dist/esm/server/lib
NameSizeModeActions
cache-handlers/-0755rm
experimental/-0755rm
incremental-cache/-0755rm
module-loader/-0755rm
router-utils/-0755rm
server-ipc/-0755rm
trace/-0755rm
app-dir-module.js11640644editdlrm
app-dir-module.js.map25980644editdlrm
app-info-log.js27230644editdlrm
app-info-log.js.map58270644editdlrm
async-callback-set.js5190644editdlrm
async-callback-set.js.map10970644editdlrm
cache-control.js5830644editdlrm
cache-control.js.map16220644editdlrm
chrome-devtools-workspace.js22970644editdlrm
chrome-devtools-workspace.js.map41450644editdlrm
clone-response.js28830644editdlrm
clone-response.js.map44410644editdlrm
cpu-profile.js10200644editdlrm
cpu-profile.js.map20610644editdlrm
decode-query-path-parameter.js4580644editdlrm
decode-query-path-parameter.js.map7400644editdlrm
dedupe-fetch.js50850644editdlrm
dedupe-fetch.js.map73740644editdlrm
dev-bundler-service.js31100644editdlrm
dev-bundler-service.js.map58380644editdlrm
disk-lru-cache.external.js18570644editdlrm
disk-lru-cache.external.js.map31490644editdlrm
etag.js11480644editdlrm
etag.js.map21650644editdlrm
find-page-file.js54450644editdlrm
find-page-file.js.map94800644editdlrm
fix-mojibake.js5230644editdlrm
fix-mojibake.js.map10260644editdlrm
format-hostname.js3320644editdlrm
format-hostname.js.map6160644editdlrm
i18n-provider.js55310644editdlrm
i18n-provider.js.map90410644editdlrm
implicit-tags.js24500644editdlrm
implicit-tags.js.map52380644editdlrm
is-ipv6.js20900644editdlrm
is-ipv6.js.map33880644editdlrm
lazy-result.js9390644editdlrm
lazy-result.js.map18690644editdlrm
lru-cache.js71480644editdlrm
lru-cache.js.map113740644editdlrm
match-next-data-pathname.js3120644editdlrm
match-next-data-pathname.js.map6290644editdlrm
mock-request.js137530644editdlrm
mock-request.js.map212240644editdlrm
node-fs-methods.js3640644editdlrm
node-fs-methods.js.map9460644editdlrm
parse-stack.js15610644editdlrm
parse-stack.js.map29830644editdlrm
patch-fetch.js449390644editdlrm
patch-fetch.js.map647210644editdlrm
patch-set-header.js13680644editdlrm
patch-set-header.js.map24710644editdlrm
render-server.js29880644editdlrm
render-server.js.map62760644editdlrm
router-server.js300290644editdlrm
router-server.js.map467520644editdlrm
server-action-request-meta.js15300644editdlrm
server-action-request-meta.js.map30300644editdlrm
source-maps.js81720644editdlrm
source-maps.js.map148120644editdlrm
start-server.js167970644editdlrm
start-server.js.map277270644editdlrm
streaming-metadata.js7620644editdlrm
streaming-metadata.js.map15820644editdlrm
to-route.js5820644editdlrm
to-route.js.map8480644editdlrm
types.js460644editdlrm
types.js.map4510644editdlrm
utils.js85160644editdlrm
utils.js.map136270644editdlrm
worker-utils.js7550644editdlrm
worker-utils.js.map11200644editdlrm
Edit: /opt/canhelp/node_modules/next/dist/esm/server/lib/i18n-provider.js (5531B)
import { getRequestMeta } from '../request-meta'; /** * The I18NProvider is used to match locale aware routes, detect the locale from * the pathname and hostname and normalize the pathname by removing the locale * prefix. */ export class I18NProvider { constructor(config){ var _config_domains; this.config = config; if (!config.locales.length) { throw Object.defineProperty(new Error('Invariant: No locales provided'), "__NEXT_ERROR_CODE", { value: "E510", enumerable: false, configurable: true }); } this.lowerCaseLocales = config.locales.map((locale)=>locale.toLowerCase()); this.lowerCaseDomains = (_config_domains = config.domains) == null ? void 0 : _config_domains.map((domainLocale)=>{ var _domainLocale_locales; const domain = domainLocale.domain.toLowerCase(); return { defaultLocale: domainLocale.defaultLocale.toLowerCase(), hostname: domain.split(':', 1)[0], domain, locales: (_domainLocale_locales = domainLocale.locales) == null ? void 0 : _domainLocale_locales.map((locale)=>locale.toLowerCase()), http: domainLocale.http }; }); } /** * Detects the domain locale from the hostname and the detected locale if * provided. * * @param hostname The hostname to detect the domain locale from, this must be lowercased. * @param detectedLocale The detected locale to use if the hostname does not match. * @returns The domain locale if found, `undefined` otherwise. */ detectDomainLocale(hostname, detectedLocale) { if (!hostname || !this.lowerCaseDomains || !this.config.domains) return; if (detectedLocale) detectedLocale = detectedLocale.toLowerCase(); for(let i = 0; i < this.lowerCaseDomains.length; i++){ var // Configuration validation ensures that the locale is not repeated in // other domains locales. _domainLocale_locales; const domainLocale = this.lowerCaseDomains[i]; if (// We assume that the hostname is already lowercased. domainLocale.hostname === hostname || ((_domainLocale_locales = domainLocale.locales) == null ? void 0 : _domainLocale_locales.some((locale)=>locale === detectedLocale))) { return this.config.domains[i]; } } return; } /** * Pulls the pre-computed locale and inference results from the query * object. * * @param req the request object * @param pathname the pathname that could contain a locale prefix * @returns the locale analysis result */ fromRequest(req, pathname) { const detectedLocale = getRequestMeta(req, 'locale'); // If a locale was detected on the query, analyze the pathname to ensure // that the locale matches. if (detectedLocale) { const analysis = this.analyze(pathname); // If the analysis contained a locale we should validate it against the // query and strip it from the pathname. if (analysis.detectedLocale) { if (analysis.detectedLocale !== detectedLocale) { console.warn(`The detected locale does not match the locale in the query. Expected to find '${detectedLocale}' in '${pathname}' but found '${analysis.detectedLocale}'}`); } pathname = analysis.pathname; } } return { pathname, detectedLocale, inferredFromDefault: getRequestMeta(req, 'localeInferredFromDefault') ?? false }; } /** * Analyzes the pathname for a locale and returns the pathname without it. * * @param pathname The pathname that could contain a locale prefix. * @param options The options to use when matching the locale. * @returns The matched locale and the pathname without the locale prefix * (if any). */ analyze(pathname, options = {}) { let detectedLocale = options.defaultLocale; // By default, we assume that the default locale was inferred if there was // no detected locale. let inferredFromDefault = typeof detectedLocale === 'string'; // The first segment will be empty, because it has a leading `/`. If // there is no further segment, there is no locale (or it's the default). const segments = pathname.split('/', 2); if (!segments[1]) return { detectedLocale, pathname, inferredFromDefault }; // The second segment will contain the locale part if any. const segment = segments[1].toLowerCase(); // See if the segment matches one of the locales. If it doesn't, there is // no locale (or it's the default). const index = this.lowerCaseLocales.indexOf(segment); if (index < 0) return { detectedLocale, pathname, inferredFromDefault }; // Return the case-sensitive locale. detectedLocale = this.config.locales[index]; inferredFromDefault = false; // Remove the `/${locale}` part of the pathname. pathname = pathname.slice(detectedLocale.length + 1) || '/'; return { detectedLocale, pathname, inferredFromDefault }; } } //# sourceMappingURL=i18n-provider.js.map