@i18n-micro/path-strategy 1.1.2 → 1.2.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 +1 -2
- package/dist/{base-strategy-Cf39XK8k.js → base-strategy-DDkINDnZ.js} +63 -67
- package/dist/base-strategy-DDkINDnZ.js.map +1 -0
- package/dist/base-strategy-iCda2UF-.cjs +2 -0
- package/dist/base-strategy-iCda2UF-.cjs.map +1 -0
- package/dist/index.cjs +1 -1
- package/dist/index.d.ts +4 -6
- package/dist/index.mjs +1 -1
- package/dist/no-prefix-strategy.cjs +1 -1
- package/dist/no-prefix-strategy.d.ts +3 -4
- package/dist/no-prefix-strategy.mjs +1 -1
- package/dist/prefix-and-default-strategy.cjs +1 -1
- package/dist/prefix-and-default-strategy.d.ts +3 -4
- package/dist/prefix-and-default-strategy.mjs +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 +4 -6
- package/dist/prefix-except-default-strategy.mjs +32 -34
- package/dist/prefix-except-default-strategy.mjs.map +1 -1
- package/dist/prefix-strategy.cjs +1 -1
- package/dist/prefix-strategy.d.ts +3 -4
- package/dist/prefix-strategy.mjs +1 -1
- package/dist/types.d.ts +1 -2
- package/package.json +2 -2
- package/dist/base-strategy-BuHeTv1K.cjs +0 -2
- package/dist/base-strategy-BuHeTv1K.cjs.map +0 -1
- package/dist/base-strategy-Cf39XK8k.js.map +0 -1
|
@@ -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 * unless includeDefaultLocaleRoute is explicitly enabled.\n */\n protected shouldHavePrefix(locale: string): boolean {\n if (this.ctx.includeDefaultLocaleRoute) return true\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":"gIAiBO,MAAMA,UAAwCC,EAAAA,gBAAiB,CAK1D,iBAAiBC,EAAyB,CAClD,GAAI,KAAK,IAAI,0BAA2B,MAAO,GAC/C,GAAIA,IAAW,KAAK,IAAI,cAAe,MAAO,GAE9C,MAAMC,EAAY,KAAK,IAAI,QAAQ,KAAMC,GAAMA,EAAE,OAASF,CAAM,EAChE,MAAI,EAAAC,GAAW,SAAWA,GAAW,YAEvC,CAEU,m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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 { 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":"gIAiBO,MAAMA,UAAwCC,EAAAA,gBAAiB,CAI1D,iBAAiBC,EAAyB,CAClD,GAAIA,IAAW,KAAK,IAAI,cAAe,MAAO,GAE9C,MAAMC,EAAY,KAAK,IAAI,QAAQ,KAAMC,GAAMA,EAAE,OAASF,CAAM,EAChE,MAAI,EAAAC,GAAW,SAAWA,GAAW,YAEvC,CAEU,mBAAmBE,EAAcH,EAAgBI,EAA4B,CACrF,OAAK,KAAK,iBAAiBJ,CAAM,EAC1BK,UAAQL,EAAQM,EAAAA,cAAcH,CAAI,CAAC,EADCG,EAAAA,cAAcH,CAAI,CAE/D,CAEU,wBAAwBI,EAAkBP,EAAwB,CAC1E,OAAK,KAAK,iBAAiBA,CAAM,EAC1B,KAAK,mBAAmBO,EAAUP,CAAM,EADJO,CAE7C,CAES,kBAAkBC,EAAoBC,EAAkBC,EAA0BC,EAAkD,CAC3I,MAAMJ,EAAW,KAAK,iBAAiBG,EAAOF,CAAU,EACxD,GAAI,CAACD,EAAU,OAAOG,EAItB,IAAIE,EACJ,GAAI,KAAK,iBAAiBH,CAAQ,EAAG,CACnC,MAAMI,EAAiB,KAAK,mBAAmBN,EAAUE,CAAQ,EAC3DK,EAAoB,GAAG,KAAK,4BAAA,CAA6B,GAAGP,CAAQ,GAC1EK,EAAa,KAAK,IAAI,OAAO,SAASC,CAAc,EAAIA,EAAiBC,CAC3E,MACEF,EAAaL,EAGf,GAAI,KAAK,IAAI,OAAO,SAASK,CAAU,EAAG,CACxC,MAAMG,EAAaJ,EAAQ,kBAAkBF,CAAQ,GAAK,CAAA,EACpDO,EAAqC,CAAE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GAEvBA,CACT,CAOA,kBAAkBuD,EAAqB4B,EAAwC,CAC7E,KAAM,CAAE,kBAAAnE,EAAmB,eAAAsC,CAAA,EAAmB,KAAK,qBAAqBC,CAAW,EAG7EG,EAAK,KAAK,IAAI,mBACdC,EAAU3C,IAAsB,IAAM,IAAM4C,EAAAA,oBAAoB5C,CAAiB,EAMvF,GALI0C,IAAOA,EAAG1C,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"}
|
|
@@ -129,7 +129,7 @@ declare abstract class BasePathStrategy implements PathStrategy {
|
|
|
129
129
|
getCurrentLocale(route: ResolvedRouteLike, getDefaultLocale?: () => string | null | undefined): string;
|
|
130
130
|
/**
|
|
131
131
|
* Returns the route name for plugin translation loading.
|
|
132
|
-
* If disablePageLocales is true, returns '
|
|
132
|
+
* If disablePageLocales is true, returns 'index'.
|
|
133
133
|
*/
|
|
134
134
|
getPluginRouteName(route: ResolvedRouteLike, locale: string): string;
|
|
135
135
|
/**
|
|
@@ -229,7 +229,7 @@ declare interface PathStrategy {
|
|
|
229
229
|
getCurrentLocale(route: ResolvedRouteLike, getDefaultLocale?: () => string | null | undefined): string;
|
|
230
230
|
/**
|
|
231
231
|
* Returns the route name for plugin translation loading.
|
|
232
|
-
* If disablePageLocales is true, returns '
|
|
232
|
+
* If disablePageLocales is true, returns 'index'.
|
|
233
233
|
*/
|
|
234
234
|
getPluginRouteName(route: ResolvedRouteLike, locale: string): string;
|
|
235
235
|
/**
|
|
@@ -260,7 +260,6 @@ declare interface PathStrategyContext {
|
|
|
260
260
|
globalLocaleRoutes?: GlobalLocaleRoutes;
|
|
261
261
|
routeLocales?: Record<string, string[]>;
|
|
262
262
|
routesLocaleLinks?: Record<string, string>;
|
|
263
|
-
includeDefaultLocaleRoute?: boolean;
|
|
264
263
|
noPrefixRedirect?: boolean;
|
|
265
264
|
debug?: boolean;
|
|
266
265
|
router: RouterAdapter;
|
|
@@ -272,8 +271,7 @@ declare interface PathStrategyContext {
|
|
|
272
271
|
|
|
273
272
|
declare class PrefixExceptDefaultPathStrategy extends BasePathStrategy {
|
|
274
273
|
/**
|
|
275
|
-
* For this strategy a prefix is required for all non-default locales
|
|
276
|
-
* unless includeDefaultLocaleRoute is explicitly enabled.
|
|
274
|
+
* For this strategy a prefix is required for all non-default locales.
|
|
277
275
|
*/
|
|
278
276
|
protected shouldHavePrefix(locale: string): boolean;
|
|
279
277
|
protected buildLocalizedPath(path: string, locale: string, _isCustom: boolean): string;
|
|
@@ -342,7 +340,7 @@ declare class RouteResolver {
|
|
|
342
340
|
constructor(ctx: PathStrategyContext);
|
|
343
341
|
/**
|
|
344
342
|
* Substitutes params into path template (:key, :key(), [...key]).
|
|
345
|
-
* Uses
|
|
343
|
+
* Uses a single pre-compiled regex for all keys in one pass — no per-key RegExp allocation.
|
|
346
344
|
*/
|
|
347
345
|
resolvePathWithParams(path: string, params?: Record<string, unknown>): string;
|
|
348
346
|
/**
|
|
@@ -1,11 +1,9 @@
|
|
|
1
|
-
import { B as K, n as R, j as m, b as F, l as C, d as I, t as T, c as b, w as z, a as k, g, i as U, e as j, p as B, f as
|
|
1
|
+
import { B as K, n as R, j as m, b as F, l as C, d as I, t as T, c as b, w as z, a as k, g, i as U, e as j, p as B, f as O } from "./base-strategy-DDkINDnZ.js";
|
|
2
2
|
class L extends K {
|
|
3
3
|
/**
|
|
4
|
-
* For this strategy a prefix is required for all non-default locales
|
|
5
|
-
* unless includeDefaultLocaleRoute is explicitly enabled.
|
|
4
|
+
* For this strategy a prefix is required for all non-default locales.
|
|
6
5
|
*/
|
|
7
6
|
shouldHavePrefix(t) {
|
|
8
|
-
if (this.ctx.includeDefaultLocaleRoute) return !0;
|
|
9
7
|
if (t === this.ctx.defaultLocale) return !1;
|
|
10
8
|
const a = this.ctx.locales.find((e) => e.code === t);
|
|
11
9
|
return !(a?.baseUrl && a?.baseDefault);
|
|
@@ -21,16 +19,16 @@ class L extends K {
|
|
|
21
19
|
if (!s) return e;
|
|
22
20
|
let r;
|
|
23
21
|
if (this.shouldHavePrefix(a)) {
|
|
24
|
-
const i = this.buildLocalizedName(s, a),
|
|
25
|
-
r = this.ctx.router.hasRoute(i) ? i :
|
|
22
|
+
const i = this.buildLocalizedName(s, a), f = `${this.getLocalizedRouteNamePrefix()}${s}`;
|
|
23
|
+
r = this.ctx.router.hasRoute(i) ? i : f;
|
|
26
24
|
} else
|
|
27
25
|
r = s;
|
|
28
26
|
if (this.ctx.router.hasRoute(r)) {
|
|
29
|
-
const i = h.i18nRouteParams?.[a] || {},
|
|
30
|
-
this.shouldHavePrefix(a) ?
|
|
31
|
-
const S = this.ctx.router.resolve({ name: r, params:
|
|
27
|
+
const i = h.i18nRouteParams?.[a] || {}, f = { ...e.params || {}, ...i };
|
|
28
|
+
this.shouldHavePrefix(a) ? f.locale = a : delete f.locale;
|
|
29
|
+
const S = this.ctx.router.resolve({ name: r, params: f }), N = {
|
|
32
30
|
name: r,
|
|
33
|
-
params:
|
|
31
|
+
params: f,
|
|
34
32
|
path: S?.path,
|
|
35
33
|
fullPath: S?.fullPath,
|
|
36
34
|
query: e.query,
|
|
@@ -59,10 +57,10 @@ class L extends K {
|
|
|
59
57
|
params: s.params ?? {}
|
|
60
58
|
}, n = this.getCustomPathSegment(y, t);
|
|
61
59
|
if (n !== null) {
|
|
62
|
-
const
|
|
60
|
+
const p = this.getNestedRouteInfo(h);
|
|
63
61
|
let d;
|
|
64
|
-
if (
|
|
65
|
-
const v = this.getParentPathForTarget(
|
|
62
|
+
if (p) {
|
|
63
|
+
const v = this.getParentPathForTarget(p.parentKey, p.keyWithSlash, t, e), W = n.startsWith("/") ? n.slice(1) : n;
|
|
66
64
|
d = v ? m(v, W) : R(n);
|
|
67
65
|
} else
|
|
68
66
|
d = R(n);
|
|
@@ -114,17 +112,17 @@ class L extends K {
|
|
|
114
112
|
n = R(u);
|
|
115
113
|
if (!this.shouldHavePrefix(t))
|
|
116
114
|
return this.preserveQueryAndHash(this.applyBaseUrl(t, n), s);
|
|
117
|
-
const
|
|
118
|
-
return this.preserveQueryAndHash(this.applyBaseUrl(t,
|
|
115
|
+
const p = m(t, n);
|
|
116
|
+
return this.preserveQueryAndHash(this.applyBaseUrl(t, p), s);
|
|
119
117
|
}
|
|
120
118
|
if (r.path && r.path !== "/" && r.name) {
|
|
121
|
-
const { pathWithoutLocale: c, baseRouteName: y } = this.getPathWithoutLocaleAndBaseName(r), n = this.getCustomPathSegment(r, t),
|
|
119
|
+
const { pathWithoutLocale: c, baseRouteName: y } = this.getPathWithoutLocaleAndBaseName(r), n = this.getCustomPathSegment(r, t), p = y ? this.getNestedRouteInfo(y) : null, d = !!p;
|
|
122
120
|
let x;
|
|
123
|
-
if (n !== null && d &&
|
|
124
|
-
const v = this.getParentPathForTarget(
|
|
121
|
+
if (n !== null && d && p) {
|
|
122
|
+
const v = this.getParentPathForTarget(p.parentKey, p.keyWithSlash, t, e), W = n.startsWith("/") ? n.slice(1) : n;
|
|
125
123
|
x = m(v, W);
|
|
126
|
-
} else if (d && n === null && c && c !== "/" &&
|
|
127
|
-
const v = this.getParentPathForTarget(
|
|
124
|
+
} else if (d && n === null && c && c !== "/" && p) {
|
|
125
|
+
const v = this.getParentPathForTarget(p.parentKey, p.keyWithSlash, t, e), W = C(c);
|
|
128
126
|
x = v ? m(v, W) : c !== "/" ? c : null;
|
|
129
127
|
} else
|
|
130
128
|
x = n !== null && !d ? R(n) : c && c !== "/" ? c : null;
|
|
@@ -150,15 +148,15 @@ class L extends K {
|
|
|
150
148
|
}, y = this.getCustomPathSegment(c, t);
|
|
151
149
|
if (y !== null) {
|
|
152
150
|
const n = this.getNestedRouteInfo(h);
|
|
153
|
-
let
|
|
151
|
+
let p;
|
|
154
152
|
if (n) {
|
|
155
153
|
const x = this.getParentPathForTarget(n.parentKey, n.keyWithSlash, t, e), v = y.startsWith("/") ? y.slice(1) : y;
|
|
156
|
-
|
|
154
|
+
p = m(x || "/", v);
|
|
157
155
|
} else
|
|
158
|
-
|
|
156
|
+
p = R(y);
|
|
159
157
|
if (!this.shouldHavePrefix(t))
|
|
160
|
-
return this.preserveQueryAndHash(this.applyBaseUrl(t,
|
|
161
|
-
const d = m(t,
|
|
158
|
+
return this.preserveQueryAndHash(this.applyBaseUrl(t, p), s);
|
|
159
|
+
const d = m(t, p);
|
|
162
160
|
return this.preserveQueryAndHash(this.applyBaseUrl(t, d), s);
|
|
163
161
|
}
|
|
164
162
|
}
|
|
@@ -189,8 +187,8 @@ class L extends K {
|
|
|
189
187
|
}
|
|
190
188
|
const P = e ? this.detectLocaleFromName(e.name) : this.detectLocaleFromName(r.name), i = P ? this.getBaseRouteName(r, P) : r.name ?? null;
|
|
191
189
|
if (!i) return s;
|
|
192
|
-
const
|
|
193
|
-
name:
|
|
190
|
+
const f = this.shouldHavePrefix(t) ? this.buildLocalizedName(i, t) : i.toString(), S = I(i) ? "/" : m("/", T(i)), N = this.shouldHavePrefix(t) ? m(t, S) : S, H = this.applyBaseUrl(t, N), q = typeof H == "string" ? H : H.path ?? N, Q = {
|
|
191
|
+
name: f,
|
|
194
192
|
path: q,
|
|
195
193
|
fullPath: q,
|
|
196
194
|
params: { ...r.params, ...s.params },
|
|
@@ -212,16 +210,16 @@ class L extends K {
|
|
|
212
210
|
getRedirect(t, a) {
|
|
213
211
|
const { pathWithoutLocale: e, localeFromPath: h } = this.getPathWithoutLocale(t), s = this.shouldHavePrefix(a), r = this.ctx.globalLocaleRoutes;
|
|
214
212
|
if (r && h !== null) {
|
|
215
|
-
const
|
|
216
|
-
if (r[e] === !1 || r[
|
|
213
|
+
const f = e === "/" ? "/" : z(e);
|
|
214
|
+
if (r[e] === !1 || r[f] === !1)
|
|
217
215
|
return k(e);
|
|
218
216
|
}
|
|
219
217
|
if (h !== null) {
|
|
220
218
|
if (h === this.ctx.defaultLocale)
|
|
221
219
|
return k(e);
|
|
222
220
|
if (h === a) {
|
|
223
|
-
const
|
|
224
|
-
return U(S,
|
|
221
|
+
const f = this.buildPathWithPrefix(e, a), S = g(t);
|
|
222
|
+
return U(S, f) ? null : f;
|
|
225
223
|
}
|
|
226
224
|
return this.buildPathWithPrefix(e, a);
|
|
227
225
|
}
|
|
@@ -267,7 +265,7 @@ class L extends K {
|
|
|
267
265
|
o = R(i);
|
|
268
266
|
}
|
|
269
267
|
if (!o) {
|
|
270
|
-
const P =
|
|
268
|
+
const P = O(a).slice(0, -1);
|
|
271
269
|
o = P.length ? m("/", ...P) : "";
|
|
272
270
|
}
|
|
273
271
|
return o;
|
|
@@ -305,8 +303,8 @@ class L extends K {
|
|
|
305
303
|
const o = this.resolvePathForLocale(e, a), P = this.shouldHavePrefix(a);
|
|
306
304
|
let i;
|
|
307
305
|
P ? i = b(`/${a}${o.startsWith("/") ? o : `/${o}`}`) : i = o.startsWith("/") ? o : `/${o}`, i !== "/" && i.endsWith("/") && (i = i.slice(0, -1));
|
|
308
|
-
const
|
|
309
|
-
return U(
|
|
306
|
+
const f = g(t);
|
|
307
|
+
return U(f, i) ? null : i;
|
|
310
308
|
}
|
|
311
309
|
}
|
|
312
310
|
export {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"prefix-except-default-strategy.mjs","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 * unless includeDefaultLocaleRoute is explicitly enabled.\n */\n protected shouldHavePrefix(locale: string): boolean {\n if (this.ctx.includeDefaultLocaleRoute) return true\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":";AAiBO,MAAMA,UAAwCC,EAAiB;AAAA;AAAA;AAAA;AAAA;AAAA,EAK1D,iBAAiBC,GAAyB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AAqBoE,GAAoC;AACjE,QAAI,CAACA,EAAM,QAAO;AAClB,eAAWrF,KAAU,KAAK,IAAI;AAC5B,UAAIqF,EAAK,SAAS,IAAIrF,EAAO,IAAI,EAAE;AACjC,eAAOA,EAAO;AAGlB,WAAO;AAAA,EACT;AAAA;AAAA;AAAA;AAAA;AAAA,EAMA,qBAAqBG,GAAcK,GAAoBC,GAA0B;AAC/E,WAAIA,MAAa,KAAK,IAAI,gBACjB,IAAID,CAAU,GAAGL,CAAI,KAEvBA;AAAA,EACT;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOA,kBAAkBuD,GAAqB4B,GAAwC;AAC7E,UAAM,EAAE,mBAAAnE,GAAmB,gBAAAsC,EAAA,IAAmB,KAAK,qBAAqBC,CAAW,GAG7EG,IAAK,KAAK,IAAI,oBACdC,IAAU3C,MAAsB,MAAM,MAAM4C,EAAoB5C,CAAiB;AAMvF,QALI0C,MAAOA,EAAG1C,CAAiB,MAAM,MAAS0C,EAAGC,CAAO,MAAM,OAK1DL,MAAmB,KAAM,QAAO;AAGpC,UAAM8B,IAAa,KAAK,qBAAqBpE,GAAmBmE,CAAe,GACzEE,IAAc,KAAK,iBAAiBF,CAAe;AAGzD,QAAIlE;AACJ,IAAIoE,IACFpE,IAAaoC,EAAmB,IAAI8B,CAAe,GAAGC,EAAW,WAAW,GAAG,IAAIA,IAAa,IAAIA,CAAU,EAAE,EAAE,IAElHnE,IAAamE,EAAW,WAAW,GAAG,IAAIA,IAAa,IAAIA,CAAU,IAInEnE,MAAe,OAAOA,EAAW,SAAS,GAAG,MAC/CA,IAAaA,EAAW,MAAM,GAAG,EAAE;AAIrC,UAAMqE,IAAetB,EAAaT,CAAW;AAC7C,WAAIU,EAAWqB,GAAcrE,CAAU,IAAU,OAE1CA;AAAA,EACT;AACF;"}
|
|
1
|
+
{"version":3,"file":"prefix-except-default-strategy.mjs","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":";AAiBO,MAAMA,UAAwCC,EAAiB;AAAA;AAAA;AAAA;AAAA,EAI1D,iBAAiBC,GAAyB;AAClD,QAAIA,MAAW,KAAK,IAAI,cAAe,QAAO;AAE9C,UAAMC,IAAY,KAAK,IAAI,QAAQ,KAAK,CAACC,MAAM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AOA,EAAO;AAGlB,WAAO;AAAA,EACT;AAAA;AAAA;AAAA;AAAA;AAAA,EAMA,qBAAqBG,GAAcK,GAAoBC,GAA0B;AAC/E,WAAIA,MAAa,KAAK,IAAI,gBACjB,IAAID,CAAU,GAAGL,CAAI,KAEvBA;AAAA,EACT;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOA,kBAAkBuD,GAAqB4B,GAAwC;AAC7E,UAAM,EAAE,mBAAAnE,GAAmB,gBAAAsC,EAAA,IAAmB,KAAK,qBAAqBC,CAAW,GAG7EG,IAAK,KAAK,IAAI,oBACdC,IAAU3C,MAAsB,MAAM,MAAM4C,EAAoB5C,CAAiB;AAMvF,QALI0C,MAAOA,EAAG1C,CAAiB,MAAM,MAAS0C,EAAGC,CAAO,MAAM,OAK1DL,MAAmB,KAAM,QAAO;AAGpC,UAAM8B,IAAa,KAAK,qBAAqBpE,GAAmBmE,CAAe,GACzEE,IAAc,KAAK,iBAAiBF,CAAe;AAGzD,QAAIlE;AACJ,IAAIoE,IACFpE,IAAaoC,EAAmB,IAAI8B,CAAe,GAAGC,EAAW,WAAW,GAAG,IAAIA,IAAa,IAAIA,CAAU,EAAE,EAAE,IAElHnE,IAAamE,EAAW,WAAW,GAAG,IAAIA,IAAa,IAAIA,CAAU,IAInEnE,MAAe,OAAOA,EAAW,SAAS,GAAG,MAC/CA,IAAaA,EAAW,MAAM,GAAG,EAAE;AAIrC,UAAMqE,IAAetB,EAAaT,CAAW;AAC7C,WAAIU,EAAWqB,GAAcrE,CAAU,IAAU,OAE1CA;AAAA,EACT;AACF;"}
|
package/dist/prefix-strategy.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const l=require("./base-strategy-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const l=require("./base-strategy-iCda2UF-.cjs");class u extends l.BasePathStrategy{buildLocalizedPath(a,e,t){return l.joinUrl(e,l.normalizePath(a))}buildLocalizedRouteName(a,e){return this.buildLocalizedName(a,e)}getCanonicalPath(a,e){const t=this.getCustomPathSegment(a,e);if(!t)return null;const o=t.startsWith("/")?t:`/${t}`;return l.cleanDoubleSlashes(`/${e}${o}`)}resolveLocaleFromPath(a){const{localeFromPath:e}=this.getPathWithoutLocale(a);return e}getRedirect(a,e){const{pathWithoutLocale:t,localeFromPath:o}=this.getPathWithoutLocale(a),s=this.ctx.globalLocaleRoutes,n=t==="/"?"/":l.withoutLeadingSlash(t),i=s&&(s[t]===!1||s[n]===!1);if(i&&o!==null)return l.normalizePathForCompare(t);if(i&&o===null)return null;const r=this.buildPathWithPrefix(t,e),h=l.getCleanPath(a);return o===e&&l.isSamePath(h,r)?null:r}buildPathWithPrefix(a,e){const t=this.resolvePathForLocale(a,e);if(t==="/"||t==="")return`/${e}`;const o=`/${e}`,s=t.startsWith("/")?t:`/${t}`;return l.cleanDoubleSlashes(o+s)}formatPathForResolve(a,e,t){return`/${e}${a}`}getClientRedirect(a,e){const{pathWithoutLocale:t,localeFromPath:o}=this.getPathWithoutLocale(a),s=this.ctx.globalLocaleRoutes,n=t==="/"?"/":l.withoutLeadingSlash(t);if(s&&(s[t]===!1||s[n]===!1)||o!==null)return null;const i=this.resolvePathForLocale(t,e);let r=l.cleanDoubleSlashes(`/${e}${i.startsWith("/")?i:`/${i}`}`);r!=="/"&&r.endsWith("/")&&(r=r.slice(0,-1));const h=l.getCleanPath(a);return l.isSamePath(h,r)?null:r}}exports.PrefixPathStrategy=u;exports.Strategy=u;
|
|
2
2
|
//# sourceMappingURL=prefix-strategy.cjs.map
|
|
@@ -129,7 +129,7 @@ declare abstract class BasePathStrategy implements PathStrategy {
|
|
|
129
129
|
getCurrentLocale(route: ResolvedRouteLike, getDefaultLocale?: () => string | null | undefined): string;
|
|
130
130
|
/**
|
|
131
131
|
* Returns the route name for plugin translation loading.
|
|
132
|
-
* If disablePageLocales is true, returns '
|
|
132
|
+
* If disablePageLocales is true, returns 'index'.
|
|
133
133
|
*/
|
|
134
134
|
getPluginRouteName(route: ResolvedRouteLike, locale: string): string;
|
|
135
135
|
/**
|
|
@@ -229,7 +229,7 @@ declare interface PathStrategy {
|
|
|
229
229
|
getCurrentLocale(route: ResolvedRouteLike, getDefaultLocale?: () => string | null | undefined): string;
|
|
230
230
|
/**
|
|
231
231
|
* Returns the route name for plugin translation loading.
|
|
232
|
-
* If disablePageLocales is true, returns '
|
|
232
|
+
* If disablePageLocales is true, returns 'index'.
|
|
233
233
|
*/
|
|
234
234
|
getPluginRouteName(route: ResolvedRouteLike, locale: string): string;
|
|
235
235
|
/**
|
|
@@ -260,7 +260,6 @@ declare interface PathStrategyContext {
|
|
|
260
260
|
globalLocaleRoutes?: GlobalLocaleRoutes;
|
|
261
261
|
routeLocales?: Record<string, string[]>;
|
|
262
262
|
routesLocaleLinks?: Record<string, string>;
|
|
263
|
-
includeDefaultLocaleRoute?: boolean;
|
|
264
263
|
noPrefixRedirect?: boolean;
|
|
265
264
|
debug?: boolean;
|
|
266
265
|
router: RouterAdapter;
|
|
@@ -320,7 +319,7 @@ declare class RouteResolver {
|
|
|
320
319
|
constructor(ctx: PathStrategyContext);
|
|
321
320
|
/**
|
|
322
321
|
* Substitutes params into path template (:key, :key(), [...key]).
|
|
323
|
-
* Uses
|
|
322
|
+
* Uses a single pre-compiled regex for all keys in one pass — no per-key RegExp allocation.
|
|
324
323
|
*/
|
|
325
324
|
resolvePathWithParams(path: string, params?: Record<string, unknown>): string;
|
|
326
325
|
/**
|
package/dist/prefix-strategy.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { B as g, j as m, n as f, c as h, w as u, a as d, g as c, i as P } from "./base-strategy-
|
|
1
|
+
import { B as g, j as m, n as f, c as h, w as u, a as d, g as c, i as P } from "./base-strategy-DDkINDnZ.js";
|
|
2
2
|
class $ extends g {
|
|
3
3
|
buildLocalizedPath(a, e, t) {
|
|
4
4
|
return m(e, f(a));
|