@i18n-micro/path-strategy 1.1.3 → 1.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +75 -29
- package/dist/base-strategy-BHkH418r.cjs +2 -0
- package/dist/base-strategy-BHkH418r.cjs.map +1 -0
- package/dist/base-strategy-CSEFam3u.js +585 -0
- package/dist/base-strategy-CSEFam3u.js.map +1 -0
- package/dist/common-BaGdobUC.js +114 -0
- package/dist/common-BaGdobUC.js.map +1 -0
- package/dist/common-sNHyO9pg.cjs +2 -0
- package/dist/common-sNHyO9pg.cjs.map +1 -0
- package/dist/index.cjs +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +63 -352
- package/dist/index.mjs +21 -34
- package/dist/index.mjs.map +1 -1
- package/dist/no-prefix-strategy.cjs +1 -1
- package/dist/no-prefix-strategy.cjs.map +1 -1
- package/dist/no-prefix-strategy.d.ts +38 -262
- package/dist/no-prefix-strategy.mjs +17 -32
- package/dist/no-prefix-strategy.mjs.map +1 -1
- package/dist/prefix-and-default-strategy.cjs +1 -1
- package/dist/prefix-and-default-strategy.cjs.map +1 -1
- package/dist/prefix-and-default-strategy.d.ts +36 -259
- package/dist/prefix-and-default-strategy.mjs +75 -125
- package/dist/prefix-and-default-strategy.mjs.map +1 -1
- package/dist/prefix-except-default-strategy.cjs +1 -1
- package/dist/prefix-except-default-strategy.cjs.map +1 -1
- package/dist/prefix-except-default-strategy.d.ts +41 -269
- package/dist/prefix-except-default-strategy.mjs +228 -251
- package/dist/prefix-except-default-strategy.mjs.map +1 -1
- package/dist/prefix-strategy.cjs +1 -1
- package/dist/prefix-strategy.cjs.map +1 -1
- package/dist/prefix-strategy.d.ts +36 -257
- package/dist/prefix-strategy.mjs +16 -53
- package/dist/prefix-strategy.mjs.map +1 -1
- package/dist/types.d.ts +23 -78
- package/package.json +6 -4
- package/dist/base-strategy-BNdOdpRE.cjs +0 -2
- package/dist/base-strategy-BNdOdpRE.cjs.map +0 -1
- package/dist/base-strategy-DmOQzfP1.js +0 -922
- package/dist/base-strategy-DmOQzfP1.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"prefix-and-default-strategy.mjs","sources":["../src/strategies/prefix-and-default.ts"],"sourcesContent":["import { isSamePath, withLeadingSlash, withoutLeadingSlash } from 'ufo'\nimport type { NormalizedRouteInput, ResolvedRouteLike, RouteLike, SwitchLocaleOptions } from '../core/types'\nimport { buildUrl, getCleanPath, joinUrl, normalizePath, normalizePathForCompare, transformNameKeyToPath } from '../utils/path'\nimport { isIndexRouteName } from '../utils/route-name'\nimport { BasePathStrategy } from './base-strategy'\n\n/**\n * prefix_and_default: default locale has both /path and /en/path.\n * We use prefixed route names for consistency (localized-name-en).\n */\nexport class PrefixAndDefaultPathStrategy extends BasePathStrategy {\n protected buildLocalizedPath(path: string, locale: string, _isCustom: boolean): string {\n return joinUrl(locale, normalizePath(path))\n }\n\n protected buildLocalizedRouteName(baseName: string, locale: string): string {\n return this.buildLocalizedName(baseName, locale)\n }\n\n override switchLocaleRoute(fromLocale: string, toLocale: string, route: ResolvedRouteLike, options: SwitchLocaleOptions): RouteLike | string {\n const baseName = this.getBaseRouteName(route, fromLocale)\n if (!baseName) return route\n\n // Try route name with locale suffix first (custom paths), then without suffix (standard routes)\n const nameWithSuffix = this.buildLocalizedName(baseName, toLocale)\n const nameWithoutSuffix = `${this.getLocalizedRouteNamePrefix()}${baseName}`\n let targetName: string\n let needsLocaleParam = false\n\n if (this.ctx.router.hasRoute(nameWithSuffix)) {\n targetName = nameWithSuffix\n } else if (this.ctx.router.hasRoute(nameWithoutSuffix)) {\n targetName = nameWithoutSuffix\n needsLocaleParam = true\n } else if (this.ctx.router.hasRoute(baseName)) {\n targetName = baseName\n } else {\n return { ...route, name: nameWithSuffix }\n }\n\n const i18nParams = options.i18nRouteParams?.[toLocale] || {}\n const newParams: Record<string, unknown> = { ...(route.params || {}), ...i18nParams }\n if (needsLocaleParam) {\n newParams.locale = toLocale\n } else {\n delete (newParams as Record<string, unknown>).locale\n }\n\n return this.applyBaseUrl(toLocale, {\n name: targetName,\n params: newParams,\n query: route.query,\n hash: route.hash,\n }) as RouteLike\n }\n\n protected override resolveLocaleRoute(\n targetLocale: string,\n normalized: NormalizedRouteInput,\n currentRoute?: ResolvedRouteLike,\n ): RouteLike | string {\n if (normalized.kind === 'path') {\n const resolvedPath = this.resolvePathForLocale(normalized.path, targetLocale)\n const prefix = `/${targetLocale}`\n return this.applyBaseUrl(targetLocale, joinUrl(prefix, withLeadingSlash(resolvedPath)))\n }\n\n const { inputName, sourceRoute, resolved } = normalized\n if (inputName) {\n const unlocalizedByName = this.getPathForUnlocalizedRouteByName(inputName)\n if (unlocalizedByName !== null) return unlocalizedByName\n }\n const hasParams = sourceRoute.params && Object.keys(sourceRoute.params ?? {}).length > 0\n if (inputName && hasParams) {\n const routeWithParams = this.tryResolveByLocalizedNameWithParams(inputName, targetLocale, sourceRoute.params ?? {}, sourceRoute)\n if (routeWithParams !== null) {\n const resolvedPath = routeWithParams.path ?? ''\n const { pathWithoutLocale } = this.getPathWithoutLocale(resolvedPath)\n const pathWithLocale =\n pathWithoutLocale === '/' || pathWithoutLocale === ''\n ? `/${targetLocale}`\n : joinUrl(`/${targetLocale}`, withLeadingSlash(pathWithoutLocale))\n const fullPathWithLocale = buildUrl(pathWithLocale, routeWithParams.query, routeWithParams.hash)\n const routeWithPath: RouteLike = {\n ...routeWithParams,\n path: pathWithLocale,\n fullPath: fullPathWithLocale,\n }\n return this.applyBaseUrl(targetLocale, routeWithPath)\n }\n }\n\n const unlocalizedPath = this.getPathForUnlocalizedRoute(resolved)\n if (unlocalizedPath !== null) return this.applyBaseUrl(targetLocale, unlocalizedPath)\n\n const customSegment = this.getCustomPathSegment(resolved, targetLocale)\n if (customSegment !== null) {\n const prefix = `/${targetLocale}`\n return this.applyBaseUrl(targetLocale, joinUrl(prefix, withLeadingSlash(customSegment)))\n }\n const baseName = this.getRouteBaseName(resolved) ?? inputName ?? resolved.name?.toString() ?? null\n if (inputName && !hasParams) {\n let routeByLocalizedName = this.tryResolveByLocalizedName(inputName, targetLocale, sourceRoute)\n const prefix = this.getLocalizedRouteNamePrefix()\n if (routeByLocalizedName === null && baseName != null && baseName !== inputName && inputName.startsWith(prefix)) {\n routeByLocalizedName = this.tryResolveByLocalizedName(baseName, targetLocale, sourceRoute)\n }\n if (routeByLocalizedName !== null) {\n // Router may return path without locale prefix (e.g. Nuxt file-based /contact). For prefix_and_default\n // we always need path with locale (e.g. /en/contact).\n const resolvedPath = routeByLocalizedName.path ?? ''\n const { pathWithoutLocale } = this.getPathWithoutLocale(resolvedPath)\n const pathWithLocale =\n pathWithoutLocale === '/' || pathWithoutLocale === ''\n ? `/${targetLocale}`\n : joinUrl(`/${targetLocale}`, withLeadingSlash(pathWithoutLocale))\n const fullPathWithLocale = buildUrl(pathWithLocale, routeByLocalizedName.query, routeByLocalizedName.hash)\n const routeWithPath: RouteLike = {\n ...routeByLocalizedName,\n path: pathWithLocale,\n fullPath: fullPathWithLocale,\n }\n return this.applyBaseUrl(targetLocale, routeWithPath)\n }\n }\n if (resolved.path && resolved.path !== '/' && resolved.name) {\n const { pathWithoutLocale } = this.getPathWithoutLocaleAndBaseName(resolved)\n if (pathWithoutLocale && pathWithoutLocale !== '/') {\n return this.applyBaseUrl(targetLocale, joinUrl(`/${targetLocale}`, withLeadingSlash(pathWithoutLocale)))\n }\n }\n\n const fromLocale = currentRoute ? this.detectLocaleFromName(currentRoute.name) : this.detectLocaleFromName(resolved.name)\n\n const fallbackBaseName = fromLocale ? this.getBaseRouteName(resolved, fromLocale) : baseName\n\n if (!fallbackBaseName) {\n // Never return unprefixed path for prefix_and_default. Build path from resolved.\n const { pathWithoutLocale } = this.getPathWithoutLocale(resolved.path ?? '/')\n const pathWithLocale =\n pathWithoutLocale === '/' || pathWithoutLocale === '' ? `/${targetLocale}` : joinUrl(`/${targetLocale}`, withLeadingSlash(pathWithoutLocale))\n const fullPathWithLocale = buildUrl(pathWithLocale, sourceRoute.query, sourceRoute.hash)\n return this.applyBaseUrl(targetLocale, {\n ...sourceRoute,\n path: pathWithLocale,\n fullPath: fullPathWithLocale,\n })\n }\n\n const targetName = this.buildLocalizedName(fallbackBaseName, targetLocale)\n\n const pathWithoutLocale = isIndexRouteName(fallbackBaseName) ? '/' : joinUrl('/', transformNameKeyToPath(fallbackBaseName))\n const pathForLocale = joinUrl(`/${targetLocale}`, withLeadingSlash(pathWithoutLocale))\n const withBase = this.applyBaseUrl(targetLocale, pathForLocale)\n const pathStr = typeof withBase === 'string' ? withBase : ((withBase as RouteLike).path ?? pathForLocale)\n\n const newRoute: RouteLike = {\n name: targetName,\n path: pathStr,\n fullPath: pathStr,\n params: { ...resolved.params, ...sourceRoute.params },\n query: { ...resolved.query, ...sourceRoute.query },\n hash: sourceRoute.hash ?? resolved.hash,\n }\n return this.applyBaseUrl(targetLocale, newRoute)\n }\n\n override getCanonicalPath(route: ResolvedRouteLike, targetLocale: string): string | null {\n const segment = this.getCustomPathSegment(route, targetLocale)\n if (!segment) return null\n return joinUrl(`/${targetLocale}`, withLeadingSlash(segment))\n }\n\n protected detectLocaleFromName(name: string | null): string | null {\n if (!name) return null\n for (const locale of this.ctx.locales) {\n if (name.endsWith(`-${locale.code}`)) {\n return locale.code\n }\n }\n return null\n }\n\n resolveLocaleFromPath(path: string): string | null {\n const { localeFromPath } = this.getPathWithoutLocale(path)\n return localeFromPath\n }\n\n getRedirect(currentPath: string, detectedLocale: string): string | null {\n const { pathWithoutLocale, localeFromPath } = this.getPathWithoutLocale(currentPath)\n // Unlocalized routes (globalLocaleRoutes[key] === false): redirect /locale/path to /path\n const gr = this.ctx.globalLocaleRoutes\n if (gr && localeFromPath !== null) {\n const pathKey = pathWithoutLocale === '/' ? '/' : withoutLeadingSlash(pathWithoutLocale)\n if (gr[pathWithoutLocale] === false || gr[pathKey] === false) {\n return normalizePathForCompare(pathWithoutLocale === '/' ? '/' : pathWithoutLocale)\n }\n }\n const expectedPath = this.buildPathWithPrefix(pathWithoutLocale, detectedLocale)\n const currentPathOnly = getCleanPath(currentPath)\n if (localeFromPath === detectedLocale && isSamePath(currentPathOnly, expectedPath)) {\n return null\n }\n return expectedPath\n }\n\n private buildPathWithPrefix(pathWithoutLocale: string, locale: string): string {\n const resolved = this.resolvePathForLocale(pathWithoutLocale, locale)\n if (resolved === '/' || resolved === '') {\n return `/${locale}`\n }\n return joinUrl(`/${locale}`, resolved)\n }\n\n /**\n * Formats path for router.resolve.\n * prefix_and_default: always add locale prefix.\n */\n formatPathForResolve(path: string, fromLocale: string, _toLocale: string): string {\n return `/${fromLocale}${path}`\n }\n\n /**\n * prefix_and_default: both / and /locale are valid for any locale.\n * Does NOT redirect if user explicitly navigates to a locale path.\n * Only redirects from paths without locale prefix.\n */\n getClientRedirect(currentPath: string, _preferredLocale: string): string | null {\n const { pathWithoutLocale, localeFromPath } = this.getPathWithoutLocale(currentPath)\n\n // Check if route is unlocalized\n const gr = this.ctx.globalLocaleRoutes\n const pathKey = pathWithoutLocale === '/' ? '/' : pathWithoutLocale.replace(/^\\//, '')\n if (gr && (gr[pathWithoutLocale] === false || gr[pathKey] === false)) {\n return null // Unlocalized routes - no redirect\n }\n\n // URL has locale prefix - user explicitly navigated here, don't redirect\n if (localeFromPath !== null) return null\n\n // Root path without locale is valid for any locale - no redirect\n if (currentPath === '/' || currentPath === '') return null\n\n // Non-root path without locale - this shouldn't happen normally in prefix_and_default\n // but if it does, we could redirect. For now, let Vue Router handle it.\n return null\n }\n}\n\n/** Alias for Nuxt alias consumption. */\nexport { PrefixAndDefaultPathStrategy as Strategy }\n"],"names":["PrefixAndDefaultPathStrategy","BasePathStrategy","path","locale","_isCustom","joinUrl","normalizePath","baseName","fromLocale","toLocale","route","options","nameWithSuffix","nameWithoutSuffix","targetName","needsLocaleParam","i18nParams","newParams","targetLocale","normalized","currentRoute","resolvedPath","prefix","withLeadingSlash","inputName","sourceRoute","resolved","unlocalizedByName","hasParams","routeWithParams","pathWithoutLocale","pathWithLocale","fullPathWithLocale","buildUrl","routeWithPath","unlocalizedPath","customSegment","routeByLocalizedName","fallbackBaseName","isIndexRouteName","transformNameKeyToPath","pathForLocale","withBase","pathStr","newRoute","segment","name","localeFromPath","currentPath","detectedLocale","gr","pathKey","withoutLeadingSlash","normalizePathForCompare","expectedPath","currentPathOnly","getCleanPath","isSamePath","_toLocale","_preferredLocale"],"mappings":";AAUO,MAAMA,UAAqCC,EAAiB;AAAA,EACvD,mBAAmBC,GAAcC,GAAgBC,GAA4B;AACrF,WAAOC,EAAQF,GAAQG,EAAcJ,CAAI,CAAC;AAAA,EAC5C;AAAA,EAEU,wBAAwBK,GAAkBJ,GAAwB;AAC1E,WAAO,KAAK,mBAAmBI,GAAUJ,CAAM;AAAA,EACjD;AAAA,EAES,kBAAkBK,GAAoBC,GAAkBC,GAA0BC,GAAkD;AAC3I,UAAMJ,IAAW,KAAK,iBAAiBG,GAAOF,CAAU;AACxD,QAAI,CAACD,EAAU,QAAOG;AAGtB,UAAME,IAAiB,KAAK,mBAAmBL,GAAUE,CAAQ,GAC3DI,IAAoB,GAAG,KAAK,4BAAA,CAA6B,GAAGN,CAAQ;AAC1E,QAAIO,GACAC,IAAmB;AAEvB,QAAI,KAAK,IAAI,OAAO,SAASH,CAAc;AACzC,MAAAE,IAAaF;AAAA,aACJ,KAAK,IAAI,OAAO,SAASC,CAAiB;AACnD,MAAAC,IAAaD,GACbE,IAAmB;AAAA,aACV,KAAK,IAAI,OAAO,SAASR,CAAQ;AAC1C,MAAAO,IAAaP;AAAA;AAEb,aAAO,EAAE,GAAGG,GAAO,MAAME,EAAA;AAG3B,UAAMI,IAAaL,EAAQ,kBAAkBF,CAAQ,KAAK,CAAA,GACpDQ,IAAqC,EAAE,GAAIP,EAAM,UAAU,CAAA,GAAK,GAAGM,EAAA;AACzE,WAAID,IACFE,EAAU,SAASR,IAEnB,OAAQQ,EAAsC,QAGzC,KAAK,aAAaR,G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lD,CAAU,GAAGN,CAAI;AAAA,EAC9B;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOA,kBAAkB8C,GAAqBW,GAAyC;AAC9E,UAAM,EAAE,mBAAA7B,GAAmB,gBAAAiB,EAAA,IAAmB,KAAK,qBAAqBC,CAAW,GAG7EE,IAAK,KAAK,IAAI,oBACdC,IAAUrB,MAAsB,MAAM,MAAMA,EAAkB,QAAQ,OAAO,EAAE;AASrF,WARIoB,MAAOA,EAAGpB,CAAiB,MAAM,MAASoB,EAAGC,CAAO,MAAM,OAK1DJ,MAAmB,QAGnBC,MAAgB,OAAOA,MAAgB,IAAW;AAAA,EAKxD;AACF;"}
|
|
1
|
+
{"version":3,"file":"prefix-and-default-strategy.mjs","sources":["../src/strategies/prefix-and-default.ts"],"sourcesContent":["import {\n findLocalizedRouteName,\n isUnlocalizedRoute,\n joinWithLocalePrefix,\n prefixRedirect,\n tryResolveByLocalizedName,\n tryResolveByLocalizedNameWithParams,\n} from '../helpers'\nimport { buildUrl, hasKeys, joinUrl, transformNameKeyToPath } from '../path'\nimport { analyzeRoute, getPathForUnlocalizedRoute, getPathForUnlocalizedRouteByName, isIndexRouteName, resolveCustomPath } from '../resolver'\nimport type { NormalizedRouteInput, ResolvedRouteLike, RouteLike, SwitchLocaleOptions } from '../types'\nimport { BasePathStrategy } from './base-strategy'\n\n/**\n * prefix_and_default: default locale has both /path and /en/path.\n * We use prefixed route names for consistency (localized-name-en).\n */\nexport class PrefixAndDefaultPathStrategy extends BasePathStrategy {\n switchLocaleRoute(fromLocale: string, toLocale: string, route: ResolvedRouteLike, options: SwitchLocaleOptions): RouteLike | string {\n const baseName = this.getBaseRouteName(route, fromLocale)\n if (!baseName) return route\n\n const prefix = this.getLocalizedRouteNamePrefix()\n const found = findLocalizedRouteName(this.ctx.router, prefix, baseName, toLocale)\n let targetName: string\n let needsLocaleParam = false\n\n if (found) {\n targetName = found.name\n needsLocaleParam = found.needsLocaleParam\n } else if (this.ctx.router.hasRoute(baseName)) {\n targetName = baseName\n } else {\n return { ...route, name: this.buildLocalizedName(baseName, toLocale) }\n }\n\n const i18nParams = options.i18nRouteParams?.[toLocale] || {}\n const newParams: Record<string, unknown> = { ...(route.params || {}), ...i18nParams }\n if (needsLocaleParam) {\n newParams.locale = toLocale\n } else {\n delete (newParams as Record<string, unknown>).locale\n }\n\n return this.applyBaseUrl(toLocale, {\n name: targetName,\n params: newParams,\n query: route.query,\n hash: route.hash,\n }) as RouteLike\n }\n\n private rewriteWithLocalePrefix(route: RouteLike, targetLocale: string): RouteLike {\n const resolvedPath = route.path ?? ''\n const { pathWithoutLocale } = this.getPathWithoutLocale(resolvedPath)\n const pathWithLocale = joinWithLocalePrefix(pathWithoutLocale, targetLocale)\n const fullPathWithLocale = buildUrl(pathWithLocale, route.query, route.hash)\n return { ...route, path: pathWithLocale, fullPath: fullPathWithLocale }\n }\n\n resolveLocaleRoute(targetLocale: string, normalized: NormalizedRouteInput, currentRoute?: ResolvedRouteLike): RouteLike | string {\n if (normalized.kind === 'path') {\n const resolvedPath = this.resolvePathForLocale(normalized.path, targetLocale)\n return this.applyBaseUrl(targetLocale, joinWithLocalePrefix(resolvedPath, targetLocale))\n }\n\n const { inputName, sourceRoute, resolved } = normalized\n const prefix = this.getLocalizedRouteNamePrefix()\n\n if (inputName) {\n const unlocalizedByName = getPathForUnlocalizedRouteByName(this.ctx, inputName)\n if (unlocalizedByName !== null) return unlocalizedByName\n }\n const hasParams = hasKeys(sourceRoute.params as Record<string, unknown>)\n if (inputName && hasParams) {\n const routeWithParams = tryResolveByLocalizedNameWithParams(\n this.ctx.router,\n prefix,\n inputName,\n targetLocale,\n sourceRoute.params ?? {},\n sourceRoute,\n )\n if (routeWithParams !== null) {\n return this.applyBaseUrl(targetLocale, this.rewriteWithLocalePrefix(routeWithParams, targetLocale))\n }\n }\n\n const hasGR = this.ctx._hasGR === true\n const baseName = this.getRouteBaseName(resolved) ?? inputName ?? resolved.name?.toString() ?? null\n\n if (hasGR) {\n const analysis = analyzeRoute(this.ctx, resolved)\n\n const unlocalizedPath = getPathForUnlocalizedRoute(this.ctx, resolved, analysis)\n if (unlocalizedPath !== null) return this.applyBaseUrl(targetLocale, unlocalizedPath)\n\n const customSegment = resolveCustomPath(this.ctx, resolved, targetLocale, analysis)\n if (customSegment !== null) {\n return this.applyBaseUrl(targetLocale, joinWithLocalePrefix(customSegment, targetLocale))\n }\n\n if (resolved.path && resolved.path !== '/' && resolved.name) {\n const { pathWithoutLocale } = analysis\n if (pathWithoutLocale && pathWithoutLocale !== '/') {\n return this.applyBaseUrl(targetLocale, joinWithLocalePrefix(pathWithoutLocale, targetLocale))\n }\n }\n }\n\n if (inputName && !hasParams) {\n let routeByLocalizedName = tryResolveByLocalizedName(this.ctx.router, prefix, inputName, targetLocale, sourceRoute)\n if (routeByLocalizedName === null && baseName != null && baseName !== inputName && inputName.startsWith(prefix)) {\n routeByLocalizedName = tryResolveByLocalizedName(this.ctx.router, prefix, baseName, targetLocale, sourceRoute)\n }\n if (routeByLocalizedName !== null) {\n return this.applyBaseUrl(targetLocale, this.rewriteWithLocalePrefix(routeByLocalizedName, targetLocale))\n }\n }\n\n if (!hasGR && resolved.path && resolved.path !== '/' && resolved.name) {\n const analysis = analyzeRoute(this.ctx, resolved)\n const { pathWithoutLocale } = analysis\n if (pathWithoutLocale && pathWithoutLocale !== '/') {\n return this.applyBaseUrl(targetLocale, joinWithLocalePrefix(pathWithoutLocale, targetLocale))\n }\n }\n\n const fromLocale = this.detectLocaleFromName(currentRoute ? currentRoute.name : resolved.name)\n\n const fallbackBaseName = fromLocale ? this.getBaseRouteName(resolved, fromLocale) : baseName\n\n if (!fallbackBaseName) {\n const { pathWithoutLocale } = this.getPathWithoutLocale(resolved.path ?? '/')\n const pathWithLocale = joinWithLocalePrefix(pathWithoutLocale, targetLocale)\n const fullPathWithLocale = buildUrl(pathWithLocale, sourceRoute.query, sourceRoute.hash)\n return this.applyBaseUrl(targetLocale, {\n ...sourceRoute,\n path: pathWithLocale,\n fullPath: fullPathWithLocale,\n })\n }\n\n const targetName = this.buildLocalizedName(fallbackBaseName, targetLocale)\n\n const pathWithoutLocale = isIndexRouteName(fallbackBaseName) ? '/' : joinUrl('/', transformNameKeyToPath(fallbackBaseName))\n const pathForLocale = joinWithLocalePrefix(pathWithoutLocale, targetLocale)\n const withBase = this.applyBaseUrl(targetLocale, pathForLocale)\n const pathStr = typeof withBase === 'string' ? withBase : ((withBase as RouteLike).path ?? pathForLocale)\n\n const newRoute: RouteLike = { name: targetName, path: pathStr, fullPath: pathStr }\n if (resolved.params || sourceRoute.params)\n newRoute.params = resolved.params !== sourceRoute.params ? Object.assign({}, resolved.params, sourceRoute.params) : resolved.params\n if (resolved.query || sourceRoute.query)\n newRoute.query = resolved.query !== sourceRoute.query ? Object.assign({}, resolved.query, sourceRoute.query) : resolved.query\n newRoute.hash = sourceRoute.hash || resolved.hash\n return this.applyBaseUrl(targetLocale, newRoute)\n }\n\n getRedirect(currentPath: string, detectedLocale: string): string | null {\n return prefixRedirect(this, currentPath, detectedLocale)\n }\n\n getClientRedirect(currentPath: string, _preferredLocale: string): string | null {\n const { pathWithoutLocale, localeFromPath } = this.getPathWithoutLocale(currentPath)\n if (isUnlocalizedRoute(pathWithoutLocale, this.ctx.globalLocaleRoutes)) return null\n if (localeFromPath !== null) return null\n return null\n }\n}\n\n/** Alias for Nuxt alias consumption. */\nexport { PrefixAndDefaultPathStrategy as Strategy }\n"],"names":["PrefixAndDefaultPathStrategy","BasePathStrategy","fromLocale","toLocale","route","options","baseName","prefix","found","findLocalizedRouteName","targetName","needsLocaleParam","i18nParams","newParams","targetLocale","resolvedPath","pathWithoutLocale","pathWithLocale","joinWithLocalePrefix","fullPathWithLocale","buildUrl","normalized","currentRoute","inputName","sourceRoute","resolved","unlocalizedByName","getPathForUnlocalizedRouteByName","hasParams","hasKeys","routeWithParams","tryResolveByLocalizedNameWithParams","hasGR","analysis","analyzeRoute","unlocalizedPath","getPathForUnlocalizedRoute","customSegment","resolveCustomPath","routeByLocalizedName","tryResolveByLocalizedName","fallbackBaseName","isIndexRouteName","joinUrl","transformNameKeyToPath","pathForLocale","withBase","pathStr","newRoute","currentPath","detectedLocale","prefixRedirect","_preferredLocale","localeFromPath","isUnlocalizedRoute"],"mappings":";AAiBO,MAAMA,UAAqCC,EAAiB;AAAA,EACjE,kBAAkBC,GAAoBC,GAAkBC,GAA0BC,GAAkD;AAClI,UAAMC,IAAW,KAAK,iBAAiBF,GAAOF,CAAU;AACxD,QAAI,CAACI,EAAU,QAAOF;AAEtB,UAAMG,IAAS,KAAK,4BAAA,GACdC,IAAQC,EAAuB,KAAK,IAAI,QAAQF,GAAQD,GAAUH,CAAQ;AAChF,QAAIO,GACAC,IAAmB;AAEvB,QAAIH;AACF,MAAAE,IAAaF,EAAM,MACnBG,IAAmBH,EAAM;AAAA,aAChB,KAAK,IAAI,OAAO,SAASF,CAAQ;AAC1C,MAAAI,IAAaJ;AAAA;AAEb,aAAO,EAAE,GAAGF,GAAO,MAAM,KAAK,mBAAmBE,GAAUH,CAAQ,EAAA;AAGrE,UAAMS,IAAaP,EAAQ,kBAAkBF,CAAQ,KAAK,CAAA,GACpDU,IAAqC,EAAE,GAAIT,EAAM,UAAU,CAAA,GAAK,GAAGQ,EAAA;AACzE,WAAID,IACFE,EAAU,SAASV,IAEnB,OAAQU,EAAsC,QAGzC,KAAK,aAAaV,GAAU;AAAA,MACjC,MAAMO;AAAA,MACN,QAAQG;AAAA,MACR,OAAOT,EAAM;AAAA,MACb,MAAMA,EAAM;AAAA,IAAA,CACb;AAAA,EACH;AAAA,EAEQ,wBAAwBA,GAAkBU,GAAiC;AACjF,UAAMC,IAAeX,EAAM,QAAQ,IAC7B,EAAE,mBAAAY,EAAA,IAAsB,KAAK,qBAAqBD,CAAY,GAC9DE,IAAiBC,EAAqBF,GAAmBF,CAAY,GACrEK,IAAqBC,EAASH,GAAgBb,EAAM,OAAOA,EAAM,IAAI;AAC3E,WAAO,EAAE,GAAG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ACN,UAAUE;AAAA,MAAA,CACX;AAAA,IACH;AAEA,UAAMT,IAAa,KAAK,mBAAmB+B,GAAkB3B,CAAY,GAEnEE,IAAoB0B,EAAiBD,CAAgB,IAAI,MAAME,EAAQ,KAAKC,EAAuBH,CAAgB,CAAC,GACpHI,IAAgB3B,EAAqBF,GAAmBF,CAAY,GACpEgC,IAAW,KAAK,aAAahC,GAAc+B,CAAa,GACxDE,IAAU,OAAOD,KAAa,WAAWA,IAAaA,EAAuB,QAAQD,GAErFG,IAAsB,EAAE,MAAMtC,GAAY,MAAMqC,GAAS,UAAUA,EAAA;AACzE,YAAItB,EAAS,UAAUD,EAAY,YACjCwB,EAAS,SAASvB,EAAS,WAAWD,EAAY,SAAS,OAAO,OAAO,CAAA,GAAIC,EAAS,QAAQD,EAAY,MAAM,IAAIC,EAAS,UAC3HA,EAAS,SAASD,EAAY,WAChCwB,EAAS,QAAQvB,EAAS,UAAUD,EAAY,QAAQ,OAAO,OAAO,CAAA,GAAIC,EAAS,OAAOD,EAAY,KAAK,IAAIC,EAAS,QAC1HuB,EAAS,OAAOxB,EAAY,QAAQC,EAAS,MACtC,KAAK,aAAaX,GAAckC,CAAQ;AAAA,EACjD;AAAA,EAEA,YAAYC,GAAqBC,GAAuC;AACtE,WAAOC,EAAe,MAAMF,GAAaC,CAAc;AAAA,EACzD;AAAA,EAEA,kBAAkBD,GAAqBG,GAAyC;AAC9E,UAAM,EAAE,mBAAApC,GAAmB,gBAAAqC,EAAA,IAAmB,KAAK,qBAAqBJ,CAAW;AAEnF,WADIK,EAAmBtC,GAAmB,KAAK,IAAI,kBAAkB,KACjEqC,MAAmB,MAAa;AAAA,EAEtC;AACF;"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const h=require("./base-strategy-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const h=require("./base-strategy-BHkH418r.cjs");class d extends h.BasePathStrategy{shouldHavePrefix(t){if(t===this.ctx.defaultLocale)return!1;const s=this.ctx.locales.find(a=>a.code===t);return!(s?.baseUrl&&s?.baseDefault)}buildLocalizedPath(t,s,a){return this.shouldHavePrefix(s)?h.joinUrl(s,h.normalizePath(t)):h.normalizePath(t)}buildLocalizedRouteName(t,s){return this.shouldHavePrefix(s)?this.buildLocalizedName(t,s):t}switchLocaleRoute(t,s,a,e){const r=this.getBaseRouteName(a,t);if(!r)return a;const p=this.shouldHavePrefix(s);let n;if(p){const m=h.findLocalizedRouteName(this.ctx.router,this.getLocalizedRouteNamePrefix(),r,s);n=m?m.name:this.buildLocalizedName(r,s)}else n=r;if(this.ctx.router.hasRoute(n)){const m=e.i18nRouteParams?.[s]||{},y={...a.params||{},...m};p?y.locale=s:delete y.locale;const f=this.ctx.router.resolve({name:n,params:y}),o={name:n,params:y,path:f?.path,fullPath:f?.fullPath,query:a.query,hash:a.hash};return this.applyBaseUrl(s,o)}const u=`/${t}`,i=a.path?.startsWith(u)?a.path.slice(u.length)||"/":a.path||"/",l=this.buildLocalizedPath(i,s,!1);return this.applyBaseUrl(s,{path:l,query:a.query,hash:a.hash})}resolveLocaleRoute(t,s,a){if(s.kind==="path"){const l=this.resolvePathForLocale(s.path,t);return this.shouldHavePrefix(t)?this.applyBaseUrl(t,h.joinUrl(t,l)):this.applyBaseUrl(t,l)}const{inputName:e,sourceRoute:r,resolved:p}=s,n=this.shouldHavePrefix(t),u=this.ctx._hasGR===!0,i=r.params!=null&&h.hasKeys(r.params);return u?this.resolveLocaleRouteFull(t,e,r,p,n,i,a):this.resolveLocaleRouteSimple(t,e,r,p,n,i,a)}resolveLocaleRouteSimple(t,s,a,e,r,p,n){const u=this.getLocalizedRouteNamePrefix();if(s&&p){if(!r&&this.ctx.router.hasRoute(s)){const l=this.ctx.router.resolve({name:s,params:a.params,query:a.query,hash:a.hash});if(l?.path&&l.path!=="/")return h.preserveQueryAndHash(this.applyBaseUrl(t,{name:s,path:l.path,fullPath:l.fullPath,params:l.params,query:l.query??a.query,hash:l.hash??a.hash}),a)}const i=h.tryResolveByLocalizedNameWithParams(this.ctx.router,u,s,t,a.params??{},a);if(i!==null)return h.preserveQueryAndHash(this.applyBaseUrl(t,i),a)}if(e.name!=null&&e.path&&e.path!=="/"){const i=h.analyzeRoute(this.ctx,e),{pathWithoutLocale:l,baseRouteName:m}=i;if(l&&l!=="/"){const y=m?r?this.buildLocalizedName(m,t):m:void 0,f=r?h.joinUrl(t,l):l,o={path:f,fullPath:f};return y&&(o.name=y),(e.params||a.params)&&(o.params=e.params!==a.params?Object.assign({},e.params,a.params):e.params),(e.query||a.query)&&(o.query=e.query!==a.query?Object.assign({},e.query,a.query):e.query),o.hash=a.hash||e.hash,h.preserveQueryAndHash(this.applyBaseUrl(t,o),a)}}if(s&&!p)if(r){const i=h.tryResolveByLocalizedName(this.ctx.router,u,s,t,a);if(i!==null)return h.preserveQueryAndHash(this.applyBaseUrl(t,i),a)}else{const i=this.getRouteBaseName(e)??s;if(this.ctx.router.hasRoute(i)){const l=this.ctx.router.resolve({name:i,params:a.params,query:a.query,hash:a.hash});if(l?.path)return h.preserveQueryAndHash(this.applyBaseUrl(t,{name:i,path:l.path,fullPath:l.fullPath,params:l.params,query:l.query??a.query,hash:l.hash??a.hash}),a)}}return this.resolveLocaleRouteFallback(t,e,a,r,n)}resolveLocaleRouteFull(t,s,a,e,r,p,n){const u=this.getLocalizedRouteNamePrefix();if(s){const i=h.getPathForUnlocalizedRouteByName(this.ctx,s);if(i!==null)return h.preserveQueryAndHash(i,a);const l=h.nameKeyLastSlash(s),m={name:s,path:`/${l}`,params:a.params??{}},y=h.resolveCustomPath(this.ctx,m,t);if(y!==null)return this.buildNestedCustomResult(y,s,t,r,a,n)}if(s&&p){if(!r&&this.ctx.router.hasRoute(s)){const l=this.ctx.router.resolve({name:s,params:a.params,query:a.query,hash:a.hash});if(l?.path&&l.path!=="/")return h.preserveQueryAndHash(this.applyBaseUrl(t,{name:s,path:l.path,fullPath:l.fullPath,params:l.params,query:l.query??a.query,hash:l.hash??a.hash}),a)}const i=h.tryResolveByLocalizedNameWithParams(this.ctx.router,u,s,t,a.params??{},a);if(i!==null)return h.preserveQueryAndHash(this.applyBaseUrl(t,i),a)}if(e.name!=null){const i=h.analyzeRoute(this.ctx,e),l=h.getPathForUnlocalizedRoute(this.ctx,e,i);if(l!==null)return h.preserveQueryAndHash(this.applyBaseUrl(t,l),a);const m=h.resolveCustomPath(this.ctx,e,t,i);if(m!==null){const y=e.name?.toString()??s??"";return this.buildNestedCustomResult(m,y,t,r,a,n)}if(e.path&&e.path!=="/"&&e.name){const{pathWithoutLocale:y,baseRouteName:f}=i,o=f?this.getNestedRouteInfo(f):null;let c;if(o&&y&&y!=="/"){const P=this.getParentPathForTarget(o.parentKey,o.keyWithSlash,t,n),q=h.lastPathSegment(y);c=P?h.joinUrl(P,q):y!=="/"?y:null}else c=y&&y!=="/"?y:null;if(c){const P=f?r?this.buildLocalizedName(f,t):f:void 0,q=r?h.joinUrl(t,c):c,x={path:q,fullPath:q};return P&&(x.name=P),(e.params||a.params)&&(x.params=e.params!==a.params?Object.assign({},e.params,a.params):e.params),(e.query||a.query)&&(x.query=e.query!==a.query?Object.assign({},e.query,a.query):e.query),x.hash=a.hash||e.hash,h.preserveQueryAndHash(this.applyBaseUrl(t,x),a)}}}if(s&&!p){if(r){const i=h.tryResolveByLocalizedName(this.ctx.router,u,s,t,a);if(i!==null)return h.preserveQueryAndHash(this.applyBaseUrl(t,i),a)}else if(this.ctx.router.hasRoute(s)){const i=this.ctx.router.resolve({name:s,params:a.params,query:a.query,hash:a.hash});if(i?.path)return h.preserveQueryAndHash(this.applyBaseUrl(t,{name:s,path:i.path,fullPath:i.fullPath,params:i.params,query:i.query??a.query,hash:i.hash??a.hash}),a)}}return this.resolveLocaleRouteFallback(t,e,a,r,n)}resolveLocaleRouteFallback(t,s,a,e,r){const p=r?this.detectLocaleFromName(r.name):this.detectLocaleFromName(s.name),n=p?this.getBaseRouteName(s,p):s.name??null;if(!n)return a;const u=e?this.buildLocalizedName(n,t):n.toString(),i=h.isIndexRouteName(n)?"/":h.joinUrl("/",h.transformNameKeyToPath(n)),l=e?h.joinUrl(t,i):i,m=this.applyBaseUrl(t,l),y=typeof m=="string"?m:m.path??l,f={name:u,path:y,fullPath:y};return(s.params||a.params)&&(f.params=s.params!==a.params?Object.assign({},s.params,a.params):s.params),(s.query||a.query)&&(f.query=s.query!==a.query?Object.assign({},s.query,a.query):s.query),f.hash=a.hash||s.hash,h.preserveQueryAndHash(this.applyBaseUrl(t,f),a)}getCanonicalPath(t,s){return h.buildCanonicalFromSegment(h.resolveCustomPath(this.ctx,t,s)??"",this.shouldHavePrefix(s)?s:null)}resolveLocaleFromPath(t){return super.resolveLocaleFromPath(t)??this.ctx.defaultLocale}getRedirect(t,s){const{pathWithoutLocale:a,localeFromPath:e}=this.getPathWithoutLocale(t),r=this.shouldHavePrefix(s);if(e!==null&&h.isUnlocalizedRoute(a,this.ctx.globalLocaleRoutes))return h.normalizePathForCompare(a);if(e!==null){if(e===this.ctx.defaultLocale)return h.normalizePathForCompare(a);if(e===s){const i=h.buildPrefixedPath(this,a,s),l=h.getCleanPath(t);return h.isSamePath(l,i)?null:i}return h.buildPrefixedPath(this,a,s)}if(r)return h.buildPrefixedPath(this,a,s);const p=this.resolvePathForLocale(a,s),n=p.startsWith("/")?p:`/${p}`,u=h.getCleanPath(t);return h.isSamePath(u,n)?null:n}shouldReturn404(t){const{pathWithoutLocale:s,localeFromPath:a}=this.getPathWithoutLocale(t);return a===null?null:a===this.ctx.defaultLocale&&s==="/"?"Default locale should not have prefix":super.shouldReturn404(t)}isLocaleRules(t){const s=this.ctx.globalLocaleRoutes;if(!s||!t)return!1;const a=s[t];return typeof a=="object"&&a!==null&&!Array.isArray(a)}getNestedRouteInfo(t){if(!this.ctx.globalLocaleRoutes)return null;const a=h.nameKeyLastSlash(t),e=h.nameKeyFirstSlash(t);if(a.includes("/")&&this.isLocaleRules(a))return{parentKey:h.parentKeyFromSlashKey(a),keyWithSlash:a};if(e.includes("/")&&this.isLocaleRules(e))return{parentKey:h.parentKeyFromSlashKey(e),keyWithSlash:e};const r=h.parentKeyFromSlashKey(a);if(a.includes("/")&&r&&this.isLocaleRules(r))return{parentKey:r,keyWithSlash:a};const p=h.parentKeyFromSlashKey(e);return e.includes("/")&&p&&this.isLocaleRules(p)?{parentKey:p,keyWithSlash:e}:null}buildNestedCustomResult(t,s,a,e,r,p){const n=this.getNestedRouteInfo(s);let u;if(n){const i=this.getParentPathForTarget(n.parentKey,n.keyWithSlash,a,p),l=t.charCodeAt(0)===47?t.slice(1):t;u=i?h.joinUrl(i,l):h.normalizePath(t)}else u=h.normalizePath(t);return e?h.preserveQueryAndHash(this.applyBaseUrl(a,h.joinUrl(a,u)),r):h.preserveQueryAndHash(this.applyBaseUrl(a,u),r)}getParentPathForTarget(t,s,a,e){const r=this.ctx.globalLocaleRoutes,p=t&&r?.[t]&&typeof r[t]=="object"&&!Array.isArray(r[t])?r[t]:null;let n=p?.[a]?h.normalizePath(p[a]):"";if(!n&&e?.path){const u=h.getCleanPath(e.path),{pathWithoutLocale:i}=this.getPathWithoutLocale(u);n=h.normalizePath(i)}if(!n){const u=h.getPathSegments(s).slice(0,-1);n=u.length?h.joinUrl("/",...u):""}return n}formatPathForResolve(t,s,a){return a!==this.ctx.defaultLocale?`/${s}${t}`:t}getClientRedirect(t,s){const{pathWithoutLocale:a,localeFromPath:e}=this.getPathWithoutLocale(t);if(h.isUnlocalizedRoute(a,this.ctx.globalLocaleRoutes)||e!==null)return null;const r=this.resolvePathForLocale(a,s),p=this.shouldHavePrefix(s);let n;p?n=h.cleanDoubleSlashes(`/${s}${r.startsWith("/")?r:`/${r}`}`):n=r.startsWith("/")?r:`/${r}`,n!=="/"&&n.endsWith("/")&&(n=n.slice(0,-1));const u=h.getCleanPath(t);return h.isSamePath(u,n)?null:n}}exports.PrefixExceptDefaultPathStrategy=d;exports.Strategy=d;
|
|
2
2
|
//# sourceMappingURL=prefix-except-default-strategy.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"prefix-except-default-strategy.cjs","sources":["../src/strategies/prefix-except-default.ts"],"sourcesContent":["import { cleanDoubleSlashes, isSamePath, withoutLeadingSlash } from 'ufo'\nimport type { NormalizedRouteInput, ResolvedRouteLike, RouteLike, SwitchLocaleOptions } from '../core/types'\nimport {\n getCleanPath,\n getPathSegments,\n joinUrl,\n lastPathSegment,\n nameKeyFirstSlash,\n nameKeyLastSlash,\n normalizePath,\n normalizePathForCompare,\n parentKeyFromSlashKey,\n transformNameKeyToPath,\n} from '../utils/path'\nimport { isIndexRouteName } from '../utils/route-name'\nimport { BasePathStrategy } from './base-strategy'\n\nexport class PrefixExceptDefaultPathStrategy extends BasePathStrategy {\n /**\n * For this strategy a prefix is required for all non-default locales.\n */\n protected shouldHavePrefix(locale: string): boolean {\n if (locale === this.ctx.defaultLocale) return false\n // When locale has baseUrl with baseDefault=true, no prefix needed (uses root on separate domain)\n const localeObj = this.ctx.locales.find((l) => l.code === locale)\n if (localeObj?.baseUrl && localeObj?.baseDefault) return false\n return true\n }\n\n protected buildLocalizedPath(path: string, locale: string, _isCustom: boolean): string {\n if (!this.shouldHavePrefix(locale)) return normalizePath(path)\n return joinUrl(locale, normalizePath(path))\n }\n\n protected buildLocalizedRouteName(baseName: string, locale: string): string {\n if (!this.shouldHavePrefix(locale)) return baseName\n return this.buildLocalizedName(baseName, locale)\n }\n\n override switchLocaleRoute(fromLocale: string, toLocale: string, route: ResolvedRouteLike, options: SwitchLocaleOptions): RouteLike | string {\n const baseName = this.getBaseRouteName(route, fromLocale)\n if (!baseName) return route\n\n // For non-default locale, try route name with locale suffix first (custom paths),\n // then without suffix (standard routes like \"localized-page\")\n let targetName: string\n if (this.shouldHavePrefix(toLocale)) {\n const nameWithSuffix = this.buildLocalizedName(baseName, toLocale)\n const nameWithoutSuffix = `${this.getLocalizedRouteNamePrefix()}${baseName}`\n targetName = this.ctx.router.hasRoute(nameWithSuffix) ? nameWithSuffix : nameWithoutSuffix\n } else {\n targetName = baseName\n }\n\n if (this.ctx.router.hasRoute(targetName)) {\n const i18nParams = options.i18nRouteParams?.[toLocale] || {}\n const newParams: Record<string, unknown> = { ...(route.params || {}), ...i18nParams }\n // Always set locale param for non-default locales because routes may have /:locale(...) in path\n if (this.shouldHavePrefix(toLocale)) {\n newParams.locale = toLocale\n } else {\n delete newParams.locale\n }\n\n // Resolve to get the actual path for applyBaseUrl\n const resolved = this.ctx.router.resolve({ name: targetName, params: newParams })\n const newRoute: RouteLike = {\n name: targetName,\n params: newParams,\n path: resolved?.path,\n fullPath: resolved?.fullPath,\n query: route.query,\n hash: route.hash,\n }\n\n return this.applyBaseUrl(toLocale, newRoute)\n }\n\n // Fallback: build path-based route\n const pathWithoutLocale = route.path?.replace(new RegExp(`^/${fromLocale}`), '') || '/'\n const targetPath = this.buildLocalizedPath(pathWithoutLocale, toLocale, false)\n return this.applyBaseUrl(toLocale, { path: targetPath, query: route.query, hash: route.hash })\n }\n\n protected override resolveLocaleRoute(\n targetLocale: string,\n normalized: NormalizedRouteInput,\n currentRoute?: ResolvedRouteLike,\n ): RouteLike | string {\n if (normalized.kind === 'path') {\n const path = this.resolvePathForLocale(normalized.path, targetLocale)\n if (!this.shouldHavePrefix(targetLocale)) return this.applyBaseUrl(targetLocale, path)\n const newPath = joinUrl(targetLocale, path)\n return this.applyBaseUrl(targetLocale, newPath)\n }\n\n const { inputName, sourceRoute, resolved } = normalized\n if (inputName) {\n const unlocalizedByName = this.getPathForUnlocalizedRouteByName(inputName)\n if (unlocalizedByName !== null) return this.preserveQueryAndHash(unlocalizedByName, sourceRoute)\n const keyLastSlash = nameKeyLastSlash(inputName)\n const syntheticPath = `/${keyLastSlash}`\n const syntheticResolved: ResolvedRouteLike = {\n name: inputName,\n path: syntheticPath,\n fullPath: syntheticPath,\n params: sourceRoute.params ?? {},\n }\n const customBySynthetic = this.getCustomPathSegment(syntheticResolved, targetLocale)\n if (customBySynthetic !== null) {\n const nestedInfo = this.getNestedRouteInfo(inputName)\n let pathNorm: string\n if (nestedInfo) {\n const parentPath = this.getParentPathForTarget(nestedInfo.parentKey, nestedInfo.keyWithSlash, targetLocale, currentRoute)\n const segment = customBySynthetic.startsWith('/') ? customBySynthetic.slice(1) : customBySynthetic\n pathNorm = parentPath ? joinUrl(parentPath, segment) : normalizePath(customBySynthetic)\n } else {\n pathNorm = normalizePath(customBySynthetic)\n }\n if (!this.shouldHavePrefix(targetLocale)) {\n return this.preserveQueryAndHash(this.applyBaseUrl(targetLocale, pathNorm), sourceRoute)\n }\n const newPath = joinUrl(targetLocale, pathNorm)\n return this.preserveQueryAndHash(this.applyBaseUrl(targetLocale, newPath), sourceRoute)\n }\n }\n\n const hasParams = sourceRoute.params && Object.keys(sourceRoute.params ?? {}).length > 0\n if (inputName && hasParams) {\n // For default locale, try resolving base route name first (without localized prefix)\n if (!this.shouldHavePrefix(targetLocale) && this.ctx.router.hasRoute(inputName)) {\n const resolved = this.ctx.router.resolve({\n name: inputName,\n params: sourceRoute.params,\n query: sourceRoute.query,\n hash: sourceRoute.hash,\n })\n if (resolved?.path && resolved.path !== '/') {\n const routeResult: RouteLike = {\n name: inputName,\n path: resolved.path,\n fullPath: resolved.fullPath,\n params: resolved.params,\n query: resolved.query ?? sourceRoute.query,\n hash: resolved.hash ?? sourceRoute.hash,\n }\n return this.preserveQueryAndHash(this.applyBaseUrl(targetLocale, routeResult), sourceRoute)\n }\n }\n const routeWithParams = this.tryResolveByLocalizedNameWithParams(inputName, targetLocale, sourceRoute.params ?? {}, sourceRoute)\n if (routeWithParams !== null) {\n const applied = this.applyBaseUrl(targetLocale, routeWithParams)\n return this.preserveQueryAndHash(applied, sourceRoute)\n }\n }\n\n if (resolved.name != null) {\n const unlocalizedPath = this.getPathForUnlocalizedRoute(resolved)\n if (unlocalizedPath !== null) {\n return this.preserveQueryAndHash(this.applyBaseUrl(targetLocale, unlocalizedPath), sourceRoute)\n }\n // When route has custom path for target locale (globalLocaleRoutes), build path string so href is correct\n const customSegment = this.getCustomPathSegment(resolved, targetLocale)\n if (customSegment !== null) {\n const routeName = resolved.name?.toString() ?? inputName ?? ''\n const nestedInfo = routeName ? this.getNestedRouteInfo(routeName) : null\n let path: string\n if (nestedInfo) {\n const parentPath = this.getParentPathForTarget(nestedInfo.parentKey, nestedInfo.keyWithSlash, targetLocale, currentRoute)\n const segment = customSegment.startsWith('/') ? customSegment.slice(1) : customSegment\n path = joinUrl(parentPath, segment)\n } else {\n path = normalizePath(customSegment)\n }\n if (!this.shouldHavePrefix(targetLocale)) {\n return this.preserveQueryAndHash(this.applyBaseUrl(targetLocale, path), sourceRoute)\n }\n const newPath = joinUrl(targetLocale, path)\n return this.preserveQueryAndHash(this.applyBaseUrl(targetLocale, newPath), sourceRoute)\n }\n // Use resolved path when valid. Prefer custom path for target locale; for nested routes build parent path + custom segment.\n if (resolved.path && resolved.path !== '/' && resolved.name) {\n const { pathWithoutLocale, baseRouteName } = this.getPathWithoutLocaleAndBaseName(resolved)\n const customForTarget = this.getCustomPathSegment(resolved, targetLocale)\n const nestedInfo = baseRouteName ? this.getNestedRouteInfo(baseRouteName) : null\n const isNested = !!nestedInfo\n let pathToUse: string | null\n if (customForTarget !== null && isNested && nestedInfo) {\n const parentPath = this.getParentPathForTarget(nestedInfo.parentKey, nestedInfo.keyWithSlash, targetLocale, currentRoute)\n const segment = customForTarget.startsWith('/') ? customForTarget.slice(1) : customForTarget\n pathToUse = joinUrl(parentPath, segment)\n } else if (isNested && customForTarget === null && pathWithoutLocale && pathWithoutLocale !== '/' && nestedInfo) {\n const parentPath = this.getParentPathForTarget(nestedInfo.parentKey, nestedInfo.keyWithSlash, targetLocale, currentRoute)\n const segment = lastPathSegment(pathWithoutLocale)\n pathToUse = parentPath ? joinUrl(parentPath, segment) : pathWithoutLocale !== '/' ? pathWithoutLocale : null\n } else {\n pathToUse =\n customForTarget !== null && !isNested\n ? normalizePath(customForTarget)\n : pathWithoutLocale && pathWithoutLocale !== '/'\n ? pathWithoutLocale\n : null\n }\n if (pathToUse) {\n const fromLocale = this.detectLocaleFromName(resolved.name)\n const baseName = fromLocale ? this.getBaseRouteName(resolved, fromLocale) : resolved.name ? this.getRouteBaseName(resolved) : null\n const targetName = baseName\n ? this.shouldHavePrefix(targetLocale)\n ? this.buildLocalizedName(baseName, targetLocale)\n : baseName.toString()\n : undefined\n const pathForLocale = this.shouldHavePrefix(targetLocale) ? joinUrl(targetLocale, pathToUse) : pathToUse\n const routeWithName: RouteLike = {\n ...(targetName ? { name: targetName } : {}),\n path: pathForLocale,\n fullPath: pathForLocale,\n params: { ...resolved.params, ...sourceRoute.params },\n query: { ...resolved.query, ...sourceRoute.query },\n hash: sourceRoute.hash ?? resolved.hash,\n }\n return this.preserveQueryAndHash(this.applyBaseUrl(targetLocale, routeWithName), sourceRoute)\n }\n }\n }\n // When resolved failed (e.g. router has only localized names), try getCustomPathSegment by synthetic path from inputName\n if (inputName) {\n const keyLastSlash = nameKeyLastSlash(inputName)\n const syntheticPath = `/${keyLastSlash}`\n const syntheticResolved: ResolvedRouteLike = {\n name: inputName,\n path: syntheticPath,\n fullPath: syntheticPath,\n params: sourceRoute.params ?? {},\n }\n const customBySynthetic = this.getCustomPathSegment(syntheticResolved, targetLocale)\n if (customBySynthetic !== null) {\n const nestedInfo = this.getNestedRouteInfo(inputName)\n let pathNorm: string\n if (nestedInfo) {\n const parentPath = this.getParentPathForTarget(nestedInfo.parentKey, nestedInfo.keyWithSlash, targetLocale, currentRoute)\n const segment = customBySynthetic.startsWith('/') ? customBySynthetic.slice(1) : customBySynthetic\n pathNorm = joinUrl(parentPath || '/', segment)\n } else {\n pathNorm = normalizePath(customBySynthetic)\n }\n if (!this.shouldHavePrefix(targetLocale)) {\n return this.preserveQueryAndHash(this.applyBaseUrl(targetLocale, pathNorm), sourceRoute)\n }\n const newPath = joinUrl(targetLocale, pathNorm)\n return this.preserveQueryAndHash(this.applyBaseUrl(targetLocale, newPath), sourceRoute)\n }\n }\n if (inputName && !hasParams) {\n // For default locale, try base route name first (e.g. 'index' instead of 'localized-index')\n if (!this.shouldHavePrefix(targetLocale)) {\n // Default locale: try to resolve baseName directly\n if (this.ctx.router.hasRoute(inputName)) {\n const resolvedBase = this.ctx.router.resolve({\n name: inputName,\n params: sourceRoute.params,\n query: sourceRoute.query,\n hash: sourceRoute.hash,\n })\n if (resolvedBase?.path) {\n return this.preserveQueryAndHash(\n this.applyBaseUrl(targetLocale, {\n name: inputName,\n path: resolvedBase.path,\n fullPath: resolvedBase.fullPath,\n params: resolvedBase.params,\n query: resolvedBase.query ?? sourceRoute.query,\n hash: resolvedBase.hash ?? sourceRoute.hash,\n }),\n sourceRoute,\n )\n }\n }\n } else {\n const routeByLocalizedName = this.tryResolveByLocalizedName(inputName, targetLocale, sourceRoute)\n if (routeByLocalizedName !== null) return this.preserveQueryAndHash(this.applyBaseUrl(targetLocale, routeByLocalizedName), sourceRoute)\n }\n }\n\n const fromLocale = currentRoute ? this.detectLocaleFromName(currentRoute.name) : this.detectLocaleFromName(resolved.name)\n\n const baseName = fromLocale ? this.getBaseRouteName(resolved, fromLocale) : (resolved.name ?? null)\n\n if (!baseName) return sourceRoute\n\n const targetName = this.shouldHavePrefix(targetLocale) ? this.buildLocalizedName(baseName, targetLocale) : baseName.toString()\n\n const pathWithoutLocale = isIndexRouteName(baseName) ? '/' : joinUrl('/', transformNameKeyToPath(baseName))\n const pathForLocale = this.shouldHavePrefix(targetLocale) ? joinUrl(targetLocale, pathWithoutLocale) : pathWithoutLocale\n const withBase = this.applyBaseUrl(targetLocale, pathForLocale)\n const pathStr = typeof withBase === 'string' ? withBase : ((withBase as RouteLike).path ?? pathForLocale)\n\n const newRoute: RouteLike = {\n name: targetName,\n path: pathStr,\n fullPath: pathStr,\n params: { ...resolved.params, ...sourceRoute.params },\n query: { ...resolved.query, ...sourceRoute.query },\n hash: sourceRoute.hash ?? resolved.hash,\n }\n\n return this.preserveQueryAndHash(this.applyBaseUrl(targetLocale, newRoute), sourceRoute)\n }\n\n override getCanonicalPath(route: ResolvedRouteLike, targetLocale: string): string | null {\n const segment = this.getCustomPathSegment(route, targetLocale)\n if (!segment) return null\n const normalized = segment.startsWith('/') ? segment : `/${segment}`\n if (!this.shouldHavePrefix(targetLocale)) {\n return cleanDoubleSlashes(normalized)\n }\n return cleanDoubleSlashes(`/${targetLocale}${normalized}`)\n }\n\n resolveLocaleFromPath(path: string): string | null {\n const { localeFromPath } = this.getPathWithoutLocale(path)\n if (localeFromPath) return localeFromPath\n return this.ctx.defaultLocale\n }\n\n getRedirect(currentPath: string, detectedLocale: string): string | null {\n const { pathWithoutLocale, localeFromPath } = this.getPathWithoutLocale(currentPath)\n const needPrefix = this.shouldHavePrefix(detectedLocale)\n\n // Unlocalized routes (globalLocaleRoutes[key] === false): redirect /locale/path to /path\n const gr = this.ctx.globalLocaleRoutes\n if (gr && localeFromPath !== null) {\n const pathKey = pathWithoutLocale === '/' ? '/' : withoutLeadingSlash(pathWithoutLocale)\n if (gr[pathWithoutLocale] === false || gr[pathKey] === false) {\n return normalizePathForCompare(pathWithoutLocale)\n }\n }\n\n if (localeFromPath !== null) {\n if (localeFromPath === this.ctx.defaultLocale) {\n return normalizePathForCompare(pathWithoutLocale)\n }\n if (localeFromPath === detectedLocale) {\n const expected = this.buildPathWithPrefix(pathWithoutLocale, detectedLocale)\n const currentPathOnly = getCleanPath(currentPath)\n return isSamePath(currentPathOnly, expected) ? null : expected\n }\n return this.buildPathWithPrefix(pathWithoutLocale, detectedLocale)\n }\n\n if (needPrefix) {\n return this.buildPathWithPrefix(pathWithoutLocale, detectedLocale)\n }\n const expectedPath = this.resolvePathForLocale(pathWithoutLocale, detectedLocale)\n const normalized = expectedPath.startsWith('/') ? expectedPath : `/${expectedPath}`\n const currentPathOnly = getCleanPath(currentPath)\n return isSamePath(currentPathOnly, normalized) ? null : normalized\n }\n\n override shouldReturn404(currentPath: string): string | null {\n const { pathWithoutLocale, localeFromPath } = this.getPathWithoutLocale(currentPath)\n\n // No locale in URL - no 404 from strategy perspective\n if (localeFromPath === null) return null\n\n // Default locale with prefix is 404 for prefix_except_default\n // e.g. /en when defaultLocale is 'en' and path is just the locale\n if (localeFromPath === this.ctx.defaultLocale && pathWithoutLocale === '/') {\n return 'Default locale should not have prefix'\n }\n\n // Delegate to base implementation for other checks\n return super.shouldReturn404(currentPath)\n }\n\n /** True if gr[key] is a locale rules object (Record<locale, path>). */\n private isLocaleRules(key: string): boolean {\n const gr = this.ctx.globalLocaleRoutes\n if (!gr || !key) return false\n const v = gr[key]\n return typeof v === 'object' && v !== null && !Array.isArray(v)\n }\n\n /**\n * For a nested route name (e.g. activity-locale-hiking), returns parent key and slash-key\n * when the route is nested (child or parent in globalLocaleRoutes). Otherwise null.\n */\n private getNestedRouteInfo(baseRouteName: string): { parentKey: string; keyWithSlash: string } | null {\n const gr = this.ctx.globalLocaleRoutes\n if (!gr) return null\n const keyLast = nameKeyLastSlash(baseRouteName)\n const keyFirst = nameKeyFirstSlash(baseRouteName)\n if (keyLast.includes('/') && this.isLocaleRules(keyLast)) {\n return { parentKey: parentKeyFromSlashKey(keyLast), keyWithSlash: keyLast }\n }\n if (keyFirst.includes('/') && this.isLocaleRules(keyFirst)) {\n return { parentKey: parentKeyFromSlashKey(keyFirst), keyWithSlash: keyFirst }\n }\n const parentLast = parentKeyFromSlashKey(keyLast)\n if (keyLast.includes('/') && parentLast && this.isLocaleRules(parentLast)) {\n return { parentKey: parentLast, keyWithSlash: keyLast }\n }\n const parentFirst = parentKeyFromSlashKey(keyFirst)\n if (keyFirst.includes('/') && parentFirst && this.isLocaleRules(parentFirst)) {\n return { parentKey: parentFirst, keyWithSlash: keyFirst }\n }\n return null\n }\n\n /** Parent path for target locale from gr or currentRoute. */\n private getParentPathForTarget(parentKey: string, keyWithSlash: string, targetLocale: string, currentRoute?: ResolvedRouteLike): string {\n const gr = this.ctx.globalLocaleRoutes\n const parentRules =\n parentKey && gr?.[parentKey] && typeof gr[parentKey] === 'object' && !Array.isArray(gr[parentKey])\n ? (gr[parentKey] as Record<string, string>)\n : null\n let parentPath = parentRules?.[targetLocale] ? normalizePath(parentRules[targetLocale]) : ''\n if (!parentPath && currentRoute?.path) {\n const curPathOnly = getCleanPath(currentRoute.path)\n const { pathWithoutLocale: curWithoutLocale } = this.getPathWithoutLocale(curPathOnly)\n parentPath = normalizePath(curWithoutLocale)\n }\n if (!parentPath) {\n const nameSegments = getPathSegments(keyWithSlash).slice(0, -1)\n parentPath = nameSegments.length ? joinUrl('/', ...nameSegments) : ''\n }\n return parentPath\n }\n\n private buildPathWithPrefix(pathWithoutLocale: string, locale: string): string {\n const resolved = this.resolvePathForLocale(pathWithoutLocale, locale)\n if (resolved === '/' || resolved === '') {\n return `/${locale}`\n }\n return joinUrl(`/${locale}`, resolved)\n }\n\n /**\n * Simple locale detector based on route name suffix.\n * Looks for known locale codes at the end of the name.\n */\n protected detectLocaleFromName(name: string | null): string | null {\n if (!name) return null\n for (const locale of this.ctx.locales) {\n if (name.endsWith(`-${locale.code}`)) {\n return locale.code\n }\n }\n return null\n }\n\n /**\n * Formats path for router.resolve.\n * prefix_except_default: add prefix only for non-default locale.\n */\n formatPathForResolve(path: string, fromLocale: string, toLocale: string): string {\n if (toLocale !== this.ctx.defaultLocale) {\n return `/${fromLocale}${path}`\n }\n return path\n }\n\n /**\n * prefix_except_default: redirect based on preferred locale.\n * Uses shouldHavePrefix to determine if locale needs prefix.\n * Also handles custom paths from globalLocaleRoutes.\n */\n getClientRedirect(currentPath: string, preferredLocale: string): string | null {\n const { pathWithoutLocale, localeFromPath } = this.getPathWithoutLocale(currentPath)\n\n // Check if route is unlocalized\n const gr = this.ctx.globalLocaleRoutes\n const pathKey = pathWithoutLocale === '/' ? '/' : withoutLeadingSlash(pathWithoutLocale)\n if (gr && (gr[pathWithoutLocale] === false || gr[pathKey] === false)) {\n return null // Unlocalized routes - no redirect\n }\n\n // URL has locale prefix - user explicitly navigated here, don't redirect\n if (localeFromPath !== null) return null\n\n // Resolve custom path for this locale\n const customPath = this.resolvePathForLocale(pathWithoutLocale, preferredLocale)\n const needsPrefix = this.shouldHavePrefix(preferredLocale)\n\n // Build target path\n let targetPath: string\n if (needsPrefix) {\n targetPath = cleanDoubleSlashes(`/${preferredLocale}${customPath.startsWith('/') ? customPath : `/${customPath}`}`)\n } else {\n targetPath = customPath.startsWith('/') ? customPath : `/${customPath}`\n }\n\n // Remove trailing slash (except for root)\n if (targetPath !== '/' && targetPath.endsWith('/')) {\n targetPath = targetPath.slice(0, -1)\n }\n\n // Only redirect if target differs from current\n const currentClean = getCleanPath(currentPath)\n if (isSamePath(currentClean, targetPath)) return null\n\n return targetPath\n }\n}\n\n/** Alias for Nuxt alias consumption. */\nexport { PrefixExceptDefaultPathStrategy as Strategy }\n"],"names":["PrefixExceptDefaultPathStrategy","BasePathStrategy","locale","localeObj","l","path","_isCustom","joinUrl","normalizePath","baseName","fromLocale","toLocale","route","options","targetName","nameWithSuffix","nameWithoutSuffix","i18nParams","newParams","resolved","newRoute","pathWithoutLocale","targetPath","targetLocale","normalized","currentRoute","newPath","inputName","sourceRoute","unlocalizedByName","syntheticPath","nameKeyLastSlash","syntheticResolved","customBySynthetic","nestedInfo","pathNorm","parentPath","segment","hasParams","routeResult","routeWithParams","applied","unlocalizedPath","customSegment","routeName","baseRouteName","customForTarget","isNested","pathToUse","lastPathSegment","pathForLocale","routeWithName","routeByLocalizedName","resolvedBase","isIndexRouteName","transformNameKeyToPath","withBase","pathStr","cleanDoubleSlashes","localeFromPath","currentPath","detectedLocale","needPrefix","gr","pathKey","withoutLeadingSlash","normalizePathForCompare","expected","currentPathOnly","getCleanPath","isSamePath","expectedPath","key","v","keyLast","keyFirst","nameKeyFirstSlash","parentKeyFromSlashKey","parentLast","parentFirst","parentKey","keyWithSlash","parentRules","curPathOnly","curWithoutLocale","nameSegments","getPathSegments","name","preferredLocale","customPath","needsPrefix","currentClean"],"mappings":"gIAiB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CAAiB,IAAM,IAAS0C,EAAGC,CAAO,IAAM,KAK1DL,IAAmB,KAAM,OAAO,KAGpC,MAAM8B,EAAa,KAAK,qBAAqBpE,EAAmBmE,CAAe,EACzEE,EAAc,KAAK,iBAAiBF,CAAe,EAGzD,IAAIlE,EACAoE,EACFpE,EAAaoC,EAAAA,mBAAmB,IAAI8B,CAAe,GAAGC,EAAW,WAAW,GAAG,EAAIA,EAAa,IAAIA,CAAU,EAAE,EAAE,EAElHnE,EAAamE,EAAW,WAAW,GAAG,EAAIA,EAAa,IAAIA,CAAU,GAInEnE,IAAe,KAAOA,EAAW,SAAS,GAAG,IAC/CA,EAAaA,EAAW,MAAM,EAAG,EAAE,GAIrC,MAAMqE,EAAetB,EAAAA,aAAaT,CAAW,EAC7C,OAAIU,aAAWqB,EAAcrE,CAAU,EAAU,KAE1CA,CACT,CACF"}
|
|
1
|
+
{"version":3,"file":"prefix-except-default-strategy.cjs","sources":["../src/strategies/prefix-except-default.ts"],"sourcesContent":["import {\n buildCanonicalFromSegment,\n buildPrefixedPath,\n findLocalizedRouteName,\n isUnlocalizedRoute,\n preserveQueryAndHash,\n tryResolveByLocalizedName,\n tryResolveByLocalizedNameWithParams,\n} from '../helpers'\nimport {\n cleanDoubleSlashes,\n getCleanPath,\n getPathSegments,\n hasKeys,\n isSamePath,\n joinUrl,\n lastPathSegment,\n nameKeyFirstSlash,\n nameKeyLastSlash,\n normalizePath,\n normalizePathForCompare,\n parentKeyFromSlashKey,\n transformNameKeyToPath,\n} from '../path'\nimport { analyzeRoute, getPathForUnlocalizedRoute, getPathForUnlocalizedRouteByName, isIndexRouteName, resolveCustomPath } from '../resolver'\nimport type { NormalizedRouteInput, ResolvedRouteLike, RouteLike, SwitchLocaleOptions } from '../types'\nimport { BasePathStrategy } from './base-strategy'\n\nexport class PrefixExceptDefaultPathStrategy extends BasePathStrategy {\n protected shouldHavePrefix(locale: string): boolean {\n if (locale === this.ctx.defaultLocale) return false\n const localeObj = this.ctx.locales.find((l) => l.code === locale)\n if (localeObj?.baseUrl && localeObj?.baseDefault) return false\n return true\n }\n\n override buildLocalizedPath(path: string, locale: string, _isCustom: boolean): string {\n if (!this.shouldHavePrefix(locale)) return normalizePath(path)\n return joinUrl(locale, normalizePath(path))\n }\n\n override buildLocalizedRouteName(baseName: string, locale: string): string {\n if (!this.shouldHavePrefix(locale)) return baseName\n return this.buildLocalizedName(baseName, locale)\n }\n\n switchLocaleRoute(fromLocale: string, toLocale: string, route: ResolvedRouteLike, options: SwitchLocaleOptions): RouteLike | string {\n const baseName = this.getBaseRouteName(route, fromLocale)\n if (!baseName) return route\n\n const needsPrefix = this.shouldHavePrefix(toLocale)\n let targetName: string\n\n if (needsPrefix) {\n const found = findLocalizedRouteName(this.ctx.router, this.getLocalizedRouteNamePrefix(), baseName, toLocale)\n targetName = found ? found.name : this.buildLocalizedName(baseName, toLocale)\n } else {\n targetName = baseName\n }\n\n if (this.ctx.router.hasRoute(targetName)) {\n const i18nParams = options.i18nRouteParams?.[toLocale] || {}\n const newParams: Record<string, unknown> = { ...(route.params || {}), ...i18nParams }\n if (needsPrefix) {\n newParams.locale = toLocale\n } else {\n delete newParams.locale\n }\n\n const resolved = this.ctx.router.resolve({ name: targetName, params: newParams })\n const newRoute: RouteLike = {\n name: targetName,\n params: newParams,\n path: resolved?.path,\n fullPath: resolved?.fullPath,\n query: route.query,\n hash: route.hash,\n }\n\n return this.applyBaseUrl(toLocale, newRoute)\n }\n\n const localePrefix = `/${fromLocale}`\n const pathWithoutLocale = route.path?.startsWith(localePrefix) ? route.path.slice(localePrefix.length) || '/' : route.path || '/'\n const targetPath = this.buildLocalizedPath(pathWithoutLocale, toLocale, false)\n return this.applyBaseUrl(toLocale, { path: targetPath, query: route.query, hash: route.hash })\n }\n\n resolveLocaleRoute(targetLocale: string, normalized: NormalizedRouteInput, currentRoute?: ResolvedRouteLike): RouteLike | string {\n if (normalized.kind === 'path') {\n const path = this.resolvePathForLocale(normalized.path, targetLocale)\n if (!this.shouldHavePrefix(targetLocale)) return this.applyBaseUrl(targetLocale, path)\n return this.applyBaseUrl(targetLocale, joinUrl(targetLocale, path))\n }\n\n const { inputName, sourceRoute, resolved } = normalized\n const needsPrefix = this.shouldHavePrefix(targetLocale)\n const hasGR = this.ctx._hasGR === true\n const hasParams = sourceRoute.params != null && hasKeys(sourceRoute.params as Record<string, unknown>)\n\n if (!hasGR) {\n return this.resolveLocaleRouteSimple(targetLocale, inputName, sourceRoute, resolved, needsPrefix, hasParams, currentRoute)\n }\n\n return this.resolveLocaleRouteFull(targetLocale, inputName, sourceRoute, resolved, needsPrefix, hasParams, currentRoute)\n }\n\n private resolveLocaleRouteSimple(\n targetLocale: string,\n inputName: string | null,\n sourceRoute: RouteLike,\n resolved: ResolvedRouteLike,\n needsPrefix: boolean,\n hasParams: boolean,\n currentRoute?: ResolvedRouteLike,\n ): RouteLike | string {\n const prefix = this.getLocalizedRouteNamePrefix()\n\n if (inputName && hasParams) {\n if (!needsPrefix && this.ctx.router.hasRoute(inputName)) {\n const res = this.ctx.router.resolve({ name: inputName, params: sourceRoute.params, query: sourceRoute.query, hash: sourceRoute.hash })\n if (res?.path && res.path !== '/') {\n return preserveQueryAndHash(\n this.applyBaseUrl(targetLocale, {\n name: inputName,\n path: res.path,\n fullPath: res.fullPath,\n params: res.params,\n query: res.query ?? sourceRoute.query,\n hash: res.hash ?? sourceRoute.hash,\n }),\n sourceRoute,\n )\n }\n }\n const routeWithParams = tryResolveByLocalizedNameWithParams(\n this.ctx.router,\n prefix,\n inputName,\n targetLocale,\n sourceRoute.params ?? {},\n sourceRoute,\n )\n if (routeWithParams !== null) return preserveQueryAndHash(this.applyBaseUrl(targetLocale, routeWithParams), sourceRoute)\n }\n\n if (resolved.name != null && resolved.path && resolved.path !== '/') {\n const analysis = analyzeRoute(this.ctx, resolved)\n const { pathWithoutLocale, baseRouteName } = analysis\n if (pathWithoutLocale && pathWithoutLocale !== '/') {\n const targetName = baseRouteName ? (needsPrefix ? this.buildLocalizedName(baseRouteName, targetLocale) : baseRouteName) : undefined\n const pathForLocale = needsPrefix ? joinUrl(targetLocale, pathWithoutLocale) : pathWithoutLocale\n const route: RouteLike = { path: pathForLocale, fullPath: pathForLocale }\n if (targetName) route.name = targetName\n if (resolved.params || sourceRoute.params)\n route.params = resolved.params !== sourceRoute.params ? Object.assign({}, resolved.params, sourceRoute.params) : resolved.params\n if (resolved.query || sourceRoute.query)\n route.query = resolved.query !== sourceRoute.query ? Object.assign({}, resolved.query, sourceRoute.query) : resolved.query\n route.hash = sourceRoute.hash || resolved.hash\n return preserveQueryAndHash(this.applyBaseUrl(targetLocale, route), sourceRoute)\n }\n }\n\n if (inputName && !hasParams) {\n if (!needsPrefix) {\n const baseName = this.getRouteBaseName(resolved) ?? inputName\n if (this.ctx.router.hasRoute(baseName)) {\n const res = this.ctx.router.resolve({ name: baseName, params: sourceRoute.params, query: sourceRoute.query, hash: sourceRoute.hash })\n if (res?.path) {\n return preserveQueryAndHash(\n this.applyBaseUrl(targetLocale, {\n name: baseName,\n path: res.path,\n fullPath: res.fullPath,\n params: res.params,\n query: res.query ?? sourceRoute.query,\n hash: res.hash ?? sourceRoute.hash,\n }),\n sourceRoute,\n )\n }\n }\n } else {\n const routeByLocalizedName = tryResolveByLocalizedName(this.ctx.router, prefix, inputName, targetLocale, sourceRoute)\n if (routeByLocalizedName !== null) return preserveQueryAndHash(this.applyBaseUrl(targetLocale, routeByLocalizedName), sourceRoute)\n }\n }\n\n return this.resolveLocaleRouteFallback(targetLocale, resolved, sourceRoute, needsPrefix, currentRoute)\n }\n\n private resolveLocaleRouteFull(\n targetLocale: string,\n inputName: string | null,\n sourceRoute: RouteLike,\n resolved: ResolvedRouteLike,\n needsPrefix: boolean,\n hasParams: boolean,\n currentRoute?: ResolvedRouteLike,\n ): RouteLike | string {\n const prefix = this.getLocalizedRouteNamePrefix()\n\n if (inputName) {\n const unlocalizedByName = getPathForUnlocalizedRouteByName(this.ctx, inputName)\n if (unlocalizedByName !== null) return preserveQueryAndHash(unlocalizedByName, sourceRoute)\n\n const keyLastSlash = nameKeyLastSlash(inputName)\n const syntheticResolved: ResolvedRouteLike = {\n name: inputName,\n path: `/${keyLastSlash}`,\n fullPath: `/${keyLastSlash}`,\n params: sourceRoute.params ?? {},\n }\n const customBySynthetic = resolveCustomPath(this.ctx, syntheticResolved, targetLocale)\n if (customBySynthetic !== null) {\n return this.buildNestedCustomResult(customBySynthetic, inputName, targetLocale, needsPrefix, sourceRoute, currentRoute)\n }\n }\n\n if (inputName && hasParams) {\n if (!needsPrefix && this.ctx.router.hasRoute(inputName)) {\n const res = this.ctx.router.resolve({ name: inputName, params: sourceRoute.params, query: sourceRoute.query, hash: sourceRoute.hash })\n if (res?.path && res.path !== '/') {\n return preserveQueryAndHash(\n this.applyBaseUrl(targetLocale, {\n name: inputName,\n path: res.path,\n fullPath: res.fullPath,\n params: res.params,\n query: res.query ?? sourceRoute.query,\n hash: res.hash ?? sourceRoute.hash,\n }),\n sourceRoute,\n )\n }\n }\n const routeWithParams = tryResolveByLocalizedNameWithParams(\n this.ctx.router,\n prefix,\n inputName,\n targetLocale,\n sourceRoute.params ?? {},\n sourceRoute,\n )\n if (routeWithParams !== null) return preserveQueryAndHash(this.applyBaseUrl(targetLocale, routeWithParams), sourceRoute)\n }\n\n if (resolved.name != null) {\n const analysis = analyzeRoute(this.ctx, resolved)\n\n const unlocalizedPath = getPathForUnlocalizedRoute(this.ctx, resolved, analysis)\n if (unlocalizedPath !== null) return preserveQueryAndHash(this.applyBaseUrl(targetLocale, unlocalizedPath), sourceRoute)\n\n const customSegment = resolveCustomPath(this.ctx, resolved, targetLocale, analysis)\n if (customSegment !== null) {\n const routeName = resolved.name?.toString() ?? inputName ?? ''\n return this.buildNestedCustomResult(customSegment, routeName, targetLocale, needsPrefix, sourceRoute, currentRoute)\n }\n\n if (resolved.path && resolved.path !== '/' && resolved.name) {\n const { pathWithoutLocale, baseRouteName } = analysis\n const nestedInfo = baseRouteName ? this.getNestedRouteInfo(baseRouteName) : null\n let pathToUse: string | null\n if (nestedInfo && pathWithoutLocale && pathWithoutLocale !== '/') {\n const parentPath = this.getParentPathForTarget(nestedInfo.parentKey, nestedInfo.keyWithSlash, targetLocale, currentRoute)\n const segment = lastPathSegment(pathWithoutLocale)\n pathToUse = parentPath ? joinUrl(parentPath, segment) : pathWithoutLocale !== '/' ? pathWithoutLocale : null\n } else {\n pathToUse = pathWithoutLocale && pathWithoutLocale !== '/' ? pathWithoutLocale : null\n }\n if (pathToUse) {\n const targetName = baseRouteName ? (needsPrefix ? this.buildLocalizedName(baseRouteName, targetLocale) : baseRouteName) : undefined\n const pathForLocale = needsPrefix ? joinUrl(targetLocale, pathToUse) : pathToUse\n const route: RouteLike = { path: pathForLocale, fullPath: pathForLocale }\n if (targetName) route.name = targetName\n if (resolved.params || sourceRoute.params)\n route.params = resolved.params !== sourceRoute.params ? Object.assign({}, resolved.params, sourceRoute.params) : resolved.params\n if (resolved.query || sourceRoute.query)\n route.query = resolved.query !== sourceRoute.query ? Object.assign({}, resolved.query, sourceRoute.query) : resolved.query\n route.hash = sourceRoute.hash || resolved.hash\n return preserveQueryAndHash(this.applyBaseUrl(targetLocale, route), sourceRoute)\n }\n }\n }\n\n if (inputName && !hasParams) {\n if (!needsPrefix) {\n if (this.ctx.router.hasRoute(inputName)) {\n const resolvedBase = this.ctx.router.resolve({\n name: inputName,\n params: sourceRoute.params,\n query: sourceRoute.query,\n hash: sourceRoute.hash,\n })\n if (resolvedBase?.path) {\n return preserveQueryAndHash(\n this.applyBaseUrl(targetLocale, {\n name: inputName,\n path: resolvedBase.path,\n fullPath: resolvedBase.fullPath,\n params: resolvedBase.params,\n query: resolvedBase.query ?? sourceRoute.query,\n hash: resolvedBase.hash ?? sourceRoute.hash,\n }),\n sourceRoute,\n )\n }\n }\n } else {\n const routeByLocalizedName = tryResolveByLocalizedName(this.ctx.router, prefix, inputName, targetLocale, sourceRoute)\n if (routeByLocalizedName !== null) return preserveQueryAndHash(this.applyBaseUrl(targetLocale, routeByLocalizedName), sourceRoute)\n }\n }\n\n return this.resolveLocaleRouteFallback(targetLocale, resolved, sourceRoute, needsPrefix, currentRoute)\n }\n\n private resolveLocaleRouteFallback(\n targetLocale: string,\n resolved: ResolvedRouteLike,\n sourceRoute: RouteLike,\n needsPrefix: boolean,\n currentRoute?: ResolvedRouteLike,\n ): RouteLike | string {\n const fromLocale = currentRoute ? this.detectLocaleFromName(currentRoute.name) : this.detectLocaleFromName(resolved.name)\n const baseName = fromLocale ? this.getBaseRouteName(resolved, fromLocale) : (resolved.name ?? null)\n if (!baseName) return sourceRoute\n\n const targetName = needsPrefix ? this.buildLocalizedName(baseName, targetLocale) : baseName.toString()\n const pathWithoutLocale = isIndexRouteName(baseName) ? '/' : joinUrl('/', transformNameKeyToPath(baseName))\n const pathForLocale = needsPrefix ? joinUrl(targetLocale, pathWithoutLocale) : pathWithoutLocale\n const withBase = this.applyBaseUrl(targetLocale, pathForLocale)\n const pathStr = typeof withBase === 'string' ? withBase : ((withBase as RouteLike).path ?? pathForLocale)\n\n const route: RouteLike = { name: targetName, path: pathStr, fullPath: pathStr }\n if (resolved.params || sourceRoute.params)\n route.params = resolved.params !== sourceRoute.params ? Object.assign({}, resolved.params, sourceRoute.params) : resolved.params\n if (resolved.query || sourceRoute.query)\n route.query = resolved.query !== sourceRoute.query ? Object.assign({}, resolved.query, sourceRoute.query) : resolved.query\n route.hash = sourceRoute.hash || resolved.hash\n return preserveQueryAndHash(this.applyBaseUrl(targetLocale, route), sourceRoute)\n }\n\n override getCanonicalPath(route: ResolvedRouteLike, targetLocale: string): string | null {\n return buildCanonicalFromSegment(\n resolveCustomPath(this.ctx, route, targetLocale) ?? '',\n this.shouldHavePrefix(targetLocale) ? targetLocale : null,\n )\n }\n\n override resolveLocaleFromPath(path: string): string | null {\n return super.resolveLocaleFromPath(path) ?? this.ctx.defaultLocale\n }\n\n getRedirect(currentPath: string, detectedLocale: string): string | null {\n const { pathWithoutLocale, localeFromPath } = this.getPathWithoutLocale(currentPath)\n const needPrefix = this.shouldHavePrefix(detectedLocale)\n\n if (localeFromPath !== null && isUnlocalizedRoute(pathWithoutLocale, this.ctx.globalLocaleRoutes)) {\n return normalizePathForCompare(pathWithoutLocale)\n }\n\n if (localeFromPath !== null) {\n if (localeFromPath === this.ctx.defaultLocale) {\n return normalizePathForCompare(pathWithoutLocale)\n }\n if (localeFromPath === detectedLocale) {\n const expected = buildPrefixedPath(this, pathWithoutLocale, detectedLocale)\n const currentPathOnly = getCleanPath(currentPath)\n return isSamePath(currentPathOnly, expected) ? null : expected\n }\n return buildPrefixedPath(this, pathWithoutLocale, detectedLocale)\n }\n\n if (needPrefix) {\n return buildPrefixedPath(this, pathWithoutLocale, detectedLocale)\n }\n const expectedPath = this.resolvePathForLocale(pathWithoutLocale, detectedLocale)\n const norm = expectedPath.startsWith('/') ? expectedPath : `/${expectedPath}`\n const currentPathOnly = getCleanPath(currentPath)\n return isSamePath(currentPathOnly, norm) ? null : norm\n }\n\n override shouldReturn404(currentPath: string): string | null {\n const { pathWithoutLocale, localeFromPath } = this.getPathWithoutLocale(currentPath)\n if (localeFromPath === null) return null\n if (localeFromPath === this.ctx.defaultLocale && pathWithoutLocale === '/') {\n return 'Default locale should not have prefix'\n }\n return super.shouldReturn404(currentPath)\n }\n\n private isLocaleRules(key: string): boolean {\n const gr = this.ctx.globalLocaleRoutes\n if (!gr || !key) return false\n const v = gr[key]\n return typeof v === 'object' && v !== null && !Array.isArray(v)\n }\n\n private getNestedRouteInfo(baseRouteName: string): { parentKey: string; keyWithSlash: string } | null {\n const gr = this.ctx.globalLocaleRoutes\n if (!gr) return null\n const keyLast = nameKeyLastSlash(baseRouteName)\n const keyFirst = nameKeyFirstSlash(baseRouteName)\n if (keyLast.includes('/') && this.isLocaleRules(keyLast)) {\n return { parentKey: parentKeyFromSlashKey(keyLast), keyWithSlash: keyLast }\n }\n if (keyFirst.includes('/') && this.isLocaleRules(keyFirst)) {\n return { parentKey: parentKeyFromSlashKey(keyFirst), keyWithSlash: keyFirst }\n }\n const parentLast = parentKeyFromSlashKey(keyLast)\n if (keyLast.includes('/') && parentLast && this.isLocaleRules(parentLast)) {\n return { parentKey: parentLast, keyWithSlash: keyLast }\n }\n const parentFirst = parentKeyFromSlashKey(keyFirst)\n if (keyFirst.includes('/') && parentFirst && this.isLocaleRules(parentFirst)) {\n return { parentKey: parentFirst, keyWithSlash: keyFirst }\n }\n return null\n }\n\n private buildNestedCustomResult(\n customPath: string,\n routeName: string,\n targetLocale: string,\n needsPrefix: boolean,\n sourceRoute: RouteLike,\n currentRoute?: ResolvedRouteLike,\n ): RouteLike | string {\n const nestedInfo = this.getNestedRouteInfo(routeName)\n let pathNorm: string\n if (nestedInfo) {\n const parentPath = this.getParentPathForTarget(nestedInfo.parentKey, nestedInfo.keyWithSlash, targetLocale, currentRoute)\n const segment = customPath.charCodeAt(0) === 47 ? customPath.slice(1) : customPath\n pathNorm = parentPath ? joinUrl(parentPath, segment) : normalizePath(customPath)\n } else {\n pathNorm = normalizePath(customPath)\n }\n if (!needsPrefix) return preserveQueryAndHash(this.applyBaseUrl(targetLocale, pathNorm), sourceRoute)\n return preserveQueryAndHash(this.applyBaseUrl(targetLocale, joinUrl(targetLocale, pathNorm)), sourceRoute)\n }\n\n private getParentPathForTarget(parentKey: string, keyWithSlash: string, targetLocale: string, currentRoute?: ResolvedRouteLike): string {\n const gr = this.ctx.globalLocaleRoutes\n const parentRules =\n parentKey && gr?.[parentKey] && typeof gr[parentKey] === 'object' && !Array.isArray(gr[parentKey])\n ? (gr[parentKey] as Record<string, string>)\n : null\n let parentPath = parentRules?.[targetLocale] ? normalizePath(parentRules[targetLocale]) : ''\n if (!parentPath && currentRoute?.path) {\n const curPathOnly = getCleanPath(currentRoute.path)\n const { pathWithoutLocale: curWithoutLocale } = this.getPathWithoutLocale(curPathOnly)\n parentPath = normalizePath(curWithoutLocale)\n }\n if (!parentPath) {\n const nameSegments = getPathSegments(keyWithSlash).slice(0, -1)\n parentPath = nameSegments.length ? joinUrl('/', ...nameSegments) : ''\n }\n return parentPath\n }\n\n override formatPathForResolve(path: string, fromLocale: string, toLocale: string): string {\n if (toLocale !== this.ctx.defaultLocale) {\n return `/${fromLocale}${path}`\n }\n return path\n }\n\n getClientRedirect(currentPath: string, preferredLocale: string): string | null {\n const { pathWithoutLocale, localeFromPath } = this.getPathWithoutLocale(currentPath)\n if (isUnlocalizedRoute(pathWithoutLocale, this.ctx.globalLocaleRoutes)) return null\n if (localeFromPath !== null) return null\n\n const customPath = this.resolvePathForLocale(pathWithoutLocale, preferredLocale)\n const needsPrefix = this.shouldHavePrefix(preferredLocale)\n\n let targetPath: string\n if (needsPrefix) {\n targetPath = cleanDoubleSlashes(`/${preferredLocale}${customPath.startsWith('/') ? customPath : `/${customPath}`}`)\n } else {\n targetPath = customPath.startsWith('/') ? customPath : `/${customPath}`\n }\n\n if (targetPath !== '/' && targetPath.endsWith('/')) {\n targetPath = targetPath.slice(0, -1)\n }\n\n const currentClean = getCleanPath(currentPath)\n if (isSamePath(currentClean, targetPath)) return null\n\n return targetPath\n }\n}\n\n/** Alias for Nuxt alias consumption. */\nexport { PrefixExceptDefaultPathStrategy as Strategy }\n"],"names":["PrefixExceptDefaultPathStrategy","BasePathStrategy","locale","localeObj","l","path","_isCustom","joinUrl","normalizePath","baseName","fromLocale","toLocale","route","options","needsPrefix","targetName","found","findLocalizedRouteName","i18nParams","newParams","resolved","newRoute","localePrefix","pathWithoutLocale","targetPath","targetLocale","normalized","currentRoute","inputName","sourceRoute","hasGR","hasParams","hasKeys","prefix","res","preserveQueryAndHash","routeWithParams","tryResolveByLocalizedNameWithParams","analysis","analyzeRoute","baseRouteName","pathForLocale","routeByLocalizedName","tryResolveByLocalizedName","unlocalizedByName","getPathForUnlocalizedRouteByName","keyLastSlash","nameKeyLastSlash","syntheticResolved","customBySynthetic","resolveCustomPath","unlocalizedPath","getPathForUnlocalizedRoute","customSegment","routeName","nestedInfo","pathToUse","parentPath","segment","lastPathSegment","resolvedBase","isIndexRouteName","transformNameKeyToPath","withBase","pathStr","buildCanonicalFromSegment","currentPath","detectedLocale","localeFromPath","needPrefix","isUnlocalizedRoute","normalizePathForCompare","expected","buildPrefixedPath","currentPathOnly","getCleanPath","isSamePath","expectedPath","norm","key","gr","v","keyLast","keyFirst","nameKeyFirstSlash","parentKeyFromSlashKey","parentLast","parentFirst","customPath","pathNorm","parentKey","keyWithSlash","parentRules","curPathOnly","curWithoutLocale","nameSegments","getPathSegments","preferredLocale","cleanDoubleSlashes","currentClean"],"mappings":"gIA4BO,MAAMA,UAAwCC,EAAAA,gBAAiB,CAC1D,iBAAiBC,EAAyB,CAClD,GAAIA,IAAW,KAAK,IAAI,cAAe,MAAO,GAC9C,MAAMC,EAAY,KAAK,IAAI,QAAQ,KAAMC,GAAMA,EAAE,OAASF,CAAM,EAChE,MAAI,EAAAC,GAAW,SAAWA,GAAW,YAEvC,CAES,mBAAmBE,EAAcH,EAAgBI,EAA4B,CACpF,OAAK,KAAK,iBAAiBJ,CAAM,EAC1BK,UAAQL,EAAQM,EAAAA,cAAcH,CAAI,CAAC,EADCG,EAAAA,cAAcH,CAAI,CAE/D,CAES,wBAAwBI,EAAkBP,EAAwB,CACzE,OAAK,KAAK,iBAAiBA,CAAM,EAC1B,KAAK,mBAAmBO,EAAUP,CAAM,EADJO,CAE7C,CAEA,kBAAkBC,EAAoBC,EAAkBC,EAA0BC,EAAkD,CAClI,MAAMJ,EAAW,KAAK,iBAAiBG,EAAOF,CAAU,EACxD,GAAI,CAACD,EAAU,OAAOG,EAEtB,MAAME,EAAc,KAAK,iBAAiBH,CAAQ,EAClD,IAAII,EAEJ,GAAID,EAAa,CACf,MAAME,EAAQC,yBAAuB,KAAK,IAAI,OAAQ,KAAK,4BAAA,EAA+BR,EAAUE,CAAQ,EAC5GI,EAAaC,EAAQA,EAAM,KAAO,KAAK,mBAAmBP,EAAUE,CAAQ,CAC9E,MACEI,EAAaN,EAGf,GAAI,KAAK,IA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