@i18n-micro/path-strategy 1.0.1 → 1.1.1
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/dist/base-strategy-CF5n6eGB.cjs +2 -0
- package/dist/base-strategy-CF5n6eGB.cjs.map +1 -0
- package/dist/base-strategy-PVpkf05w.js +904 -0
- package/dist/base-strategy-PVpkf05w.js.map +1 -0
- package/dist/index.cjs +1 -1
- package/dist/index.d.ts +134 -4
- package/dist/index.mjs +1 -1
- package/dist/no-prefix-strategy.cjs +1 -1
- package/dist/no-prefix-strategy.cjs.map +1 -1
- package/dist/no-prefix-strategy.d.ts +100 -4
- package/dist/no-prefix-strategy.mjs +42 -22
- package/dist/no-prefix-strategy.mjs.map +1 -1
- package/dist/prefix-and-default-strategy.cjs +1 -1
- package/dist/prefix-and-default-strategy.cjs.map +1 -1
- package/dist/prefix-and-default-strategy.d.ts +97 -4
- package/dist/prefix-and-default-strategy.mjs +104 -82
- package/dist/prefix-and-default-strategy.mjs.map +1 -1
- package/dist/prefix-except-default-strategy.cjs +1 -1
- package/dist/prefix-except-default-strategy.cjs.map +1 -1
- package/dist/prefix-except-default-strategy.d.ts +98 -4
- package/dist/prefix-except-default-strategy.mjs +243 -175
- package/dist/prefix-except-default-strategy.mjs.map +1 -1
- package/dist/prefix-strategy.cjs +1 -1
- package/dist/prefix-strategy.cjs.map +1 -1
- package/dist/prefix-strategy.d.ts +97 -4
- package/dist/prefix-strategy.mjs +35 -14
- package/dist/prefix-strategy.mjs.map +1 -1
- package/dist/types.d.ts +46 -1
- package/package.json +4 -2
- package/dist/base-strategy-B5mBf3XX.cjs +0 -2
- package/dist/base-strategy-B5mBf3XX.cjs.map +0 -1
- package/dist/base-strategy-DVqe8ehd.js +0 -790
- package/dist/base-strategy-DVqe8ehd.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"prefix-except-default-strategy.mjs","sources":["../src/strategies/prefix-except-default.ts"],"sourcesContent":["import type { NormalizedRouteInput, ResolvedRouteLike, RouteLike, SwitchLocaleOptions } from '../core/types'\nimport { BasePathStrategy } from './base-strategy'\nimport { cleanDoubleSlashes, isSamePath, withoutLeadingSlash } from 'ufo'\nimport { getCleanPath, getPathSegments, joinUrl, normalizePath, normalizePathForCompare, nameKeyFirstSlash, nameKeyLastSlash, parentKeyFromSlashKey, lastPathSegment, transformNameKeyToPath } from '../utils/path'\nimport { isIndexRouteName } from '../utils/route-name'\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 return locale !== this.ctx.defaultLocale\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(\n fromLocale: string,\n toLocale: string,\n route: ResolvedRouteLike,\n options: SwitchLocaleOptions,\n ): RouteLike | string {\n const baseName = this.getBaseRouteName(route, fromLocale)\n if (!baseName) return route\n\n const targetName = this.shouldHavePrefix(toLocale)\n ? this.buildLocalizedName(baseName, toLocale)\n : baseName\n\n if (this.ctx.router.hasRoute(targetName)) {\n const i18nParams = options.i18nRouteParams?.[toLocale] || {}\n const newParams: Record<string, unknown> = { ...(route.params || {}), ...i18nParams }\n delete newParams.locale\n\n const newRoute: RouteLike = {\n name: targetName,\n params: newParams,\n query: route.query,\n hash: route.hash,\n }\n\n return this.applyBaseUrl(toLocale, newRoute)\n }\n\n return { ...route, name: targetName }\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 }\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 const routeWithParams = this.tryResolveByLocalizedNameWithParams(\n inputName,\n targetLocale,\n sourceRoute.params ?? {},\n sourceRoute,\n )\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 }\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 }\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 }\n else {\n pathToUse = customForTarget !== null && !isNested\n ? normalizePath(customForTarget)\n : (pathWithoutLocale && pathWithoutLocale !== '/' ? pathWithoutLocale : 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) ? this.buildLocalizedName(baseName, targetLocale) : baseName.toString())\n : undefined\n const pathForLocale = this.shouldHavePrefix(targetLocale)\n ? joinUrl(targetLocale, pathToUse)\n : 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 }\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 const routeByLocalizedName = this.tryResolveByLocalizedName(inputName, targetLocale, sourceRoute)\n if (routeByLocalizedName !== null) return this.preserveQueryAndHash(this.applyBaseUrl(targetLocale, routeByLocalizedName), sourceRoute)\n }\n\n const fromLocale = currentRoute\n ? this.detectLocaleFromName(currentRoute.name)\n : this.detectLocaleFromName(resolved.name)\n\n const baseName = fromLocale\n ? this.getBaseRouteName(resolved, fromLocale)\n : resolved.name ?? null\n\n if (!baseName) return sourceRoute\n\n const targetName = this.shouldHavePrefix(targetLocale)\n ? this.buildLocalizedName(baseName, targetLocale)\n : baseName.toString()\n\n const pathWithoutLocale = isIndexRouteName(baseName)\n ? '/'\n : joinUrl('/', transformNameKeyToPath(baseName))\n const pathForLocale = this.shouldHavePrefix(targetLocale)\n ? joinUrl(targetLocale, pathWithoutLocale)\n : 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 /** 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(\n parentKey: string,\n keyWithSlash: string,\n targetLocale: string,\n currentRoute?: ResolvedRouteLike,\n ): string {\n const gr = this.ctx.globalLocaleRoutes\n const parentRules = (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/** Alias for Nuxt alias consumption. */\nexport { PrefixExceptDefaultPathStrategy as Strategy }\n"],"names":["PrefixExceptDefaultPathStrategy","BasePathStrategy","locale","path","_isCustom","joinUrl","normalizePath","baseName","fromLocale","toLocale","route","options","targetName","i18nParams","newParams","newRoute","targetLocale","normalized","currentRoute","newPath","inputName","sourceRoute","resolved","unlocalizedByName","syntheticPath","nameKeyLastSlash","syntheticResolved","customBySynthetic","nestedInfo","pathNorm","parentPath","segment","hasParams","routeWithParams","applied","unlocalizedPath","customSegment","routeName","pathWithoutLocale","baseRouteName","customForTarget","isNested","pathToUse","lastPathSegment","pathForLocale","routeWithName","routeByLocalizedName","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"],"mappings":";AAMO,MAAMA,UAAwCC,EAAiB;AAAA;AAAA;AAAA;AAAA;AAAA,EAK1D,iBAAiBC,GAAyB;AAClD,WAAI,KAAK,IAAI,4BAAkC,KACxCA,MAAW,KAAK,IAAI;AAAA,EAC7B;AAAA,EAEU,mBAAmBC,GAAcD,GAAgBE,GAA4B;AACrF,WAAK,KAAK,iBAAiBF,CAAM,IAC1BG,EAAQH,GAAQI,EAAcH,CAAI,CAAC,IADCG,EAAcH,CAAI;AAAA,EAE/D;AAAA,EAEU,wBAAwBI,GAAkBL,GAAwB;AAC1E,WAAK,KAAK,iBAAiBA,CAAM,IAC1B,KAAK,mBAAmBK,GAAUL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AAA,EACvC;AAAA;AAAA;AAAA;AAAA;AAAA,EAMU,qBAAqB0D,GAAoC;AACjE,QAAI,CAACA,EAAM,QAAO;AAClB,eAAW9E,KAAU,KAAK,IAAI;AAC5B,UAAI8E,EAAK,SAAS,IAAI9E,EAAO,IAAI,EAAE;AACjC,eAAOA,EAAO;AAGlB,WAAO;AAAA,EACT;AACF;"}
|
|
1
|
+
{"version":3,"file":"prefix-except-default-strategy.mjs","sources":["../src/strategies/prefix-except-default.ts"],"sourcesContent":["import type { NormalizedRouteInput, ResolvedRouteLike, RouteLike, SwitchLocaleOptions } from '../core/types'\nimport { BasePathStrategy } from './base-strategy'\nimport { cleanDoubleSlashes, isSamePath, withoutLeadingSlash } from 'ufo'\nimport { getCleanPath, getPathSegments, joinUrl, normalizePath, normalizePathForCompare, nameKeyFirstSlash, nameKeyLastSlash, parentKeyFromSlashKey, lastPathSegment, transformNameKeyToPath } from '../utils/path'\nimport { isIndexRouteName } from '../utils/route-name'\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(\n fromLocale: string,\n toLocale: string,\n route: ResolvedRouteLike,\n options: SwitchLocaleOptions,\n ): 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 }\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 }\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 }\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(\n inputName,\n targetLocale,\n sourceRoute.params ?? {},\n sourceRoute,\n )\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 }\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 }\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 }\n else {\n pathToUse = customForTarget !== null && !isNested\n ? normalizePath(customForTarget)\n : (pathWithoutLocale && pathWithoutLocale !== '/' ? pathWithoutLocale : 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) ? this.buildLocalizedName(baseName, targetLocale) : baseName.toString())\n : undefined\n const pathForLocale = this.shouldHavePrefix(targetLocale)\n ? joinUrl(targetLocale, pathToUse)\n : 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 }\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({ name: inputName, params: sourceRoute.params, query: sourceRoute.query, hash: sourceRoute.hash })\n if (resolvedBase?.path) {\n return this.preserveQueryAndHash(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 }), 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\n ? this.detectLocaleFromName(currentRoute.name)\n : this.detectLocaleFromName(resolved.name)\n\n const baseName = fromLocale\n ? this.getBaseRouteName(resolved, fromLocale)\n : resolved.name ?? null\n\n if (!baseName) return sourceRoute\n\n const targetName = this.shouldHavePrefix(targetLocale)\n ? this.buildLocalizedName(baseName, targetLocale)\n : baseName.toString()\n\n const pathWithoutLocale = isIndexRouteName(baseName)\n ? '/'\n : joinUrl('/', transformNameKeyToPath(baseName))\n const pathForLocale = this.shouldHavePrefix(targetLocale)\n ? joinUrl(targetLocale, pathWithoutLocale)\n : 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(\n parentKey: string,\n keyWithSlash: string,\n targetLocale: string,\n currentRoute?: ResolvedRouteLike,\n ): string {\n const gr = this.ctx.globalLocaleRoutes\n const parentRules = (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 }\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":";AAMO,MAAMA,UAAwCC,EAAiB;AAAA;AAAA;AAAA;AAAA;AAAA,EAK1D,iBAAiBC,GAAyB;AAClD,QAAI,KAAK,IAAI,0BAA2B,QAAO;AAC/C,QAAIA,MAAW,KAAK,IAAI,cAAe,QAAO;AAE9C,UAAMC,IAAY,KAAK,IAAI,QAAQ,KAAK,CAAAC,MAAKA,EAAE,SAASF,CAAM;AAC9D,WAAI,EAAAC,GAAW,WAAWA,GAAW;AAAA,EAEvC;AAAA,EAEU,mBAAmBE,GAAcH,GAAgBI,GAA4B;AACrF,WAAK,KAAK,iBAAiBJ,CAAM,IAC1BK,EAAQL,GAAQM,EAAcH,CAAI,CAAC,IADCG,EAAcH,CAAI;AAAA,EAE/D;AAAA,EAEU,wBAAwBI,GAAkBP,GAAwB;AAC1E,WAAK,KAAK,iBAAiBA,CAAM,IAC1B,KAAK,mBAAmBO,GAAUP,CAAM,IADJO;AAAA,EAE7C;AAAA,EAES,kBACPC,GACAC,GACAC,GACAC,GACoB;AACpB,UAAMJ,IAAW,KAAK,iBAAiBG,GAAOF,CAAU;AACxD,QAAI,CAACD,EAAU,QAAOG;AAItB,QAAIE;AACJ,QAAI,KAAK,iBAAiBH,CAAQ,GAAG;AACnC,YAAMI,IAAiB,KAAK,mBAAmBN,GAAUE,CAAQ,GAC3DK,IAAoB,GAAG,KAAK,4BAAA,CAA6B,GAAGP,CAAQ;AAC1E,MAAAK,IAAa,KAAK,IAAI,OAAO,SAASC,CAAc,IAAIA,IAAiBC;AAAA,IAC3E;AAEE,MAAAF,IAAaL;AAGf,QAAI,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AIA,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
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const l=require("./base-strategy-CF5n6eGB.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
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"prefix-strategy.cjs","sources":["../src/strategies/prefix.ts"],"sourcesContent":["import type { ResolvedRouteLike } from '../core/types'\nimport { BasePathStrategy } from './base-strategy'\nimport { cleanDoubleSlashes, isSamePath, withoutLeadingSlash } from 'ufo'\nimport { getCleanPath, joinUrl, normalizePath, normalizePathForCompare } from '../utils/path'\n\nexport class PrefixPathStrategy extends BasePathStrategy {\n protected buildLocalizedPath(path: string, locale: string, _isCustom: boolean): string {\n return joinUrl(locale, normalizePath(path))\n }\n\n protected buildLocalizedRouteName(baseName: string, locale: string): string {\n return this.buildLocalizedName(baseName, locale)\n }\n\n override 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 return cleanDoubleSlashes(`/${targetLocale}${normalized}`)\n }\n\n resolveLocaleFromPath(path: string): string | null {\n const { localeFromPath } = this.getPathWithoutLocale(path)\n return localeFromPath\n }\n\n getRedirect(currentPath: string, detectedLocale: string): string | null {\n const { pathWithoutLocale, localeFromPath } = this.getPathWithoutLocale(currentPath)\n const gr = this.ctx.globalLocaleRoutes\n const pathKey = pathWithoutLocale === '/' ? '/' : withoutLeadingSlash(pathWithoutLocale)\n const isUnlocalized = gr && (gr[pathWithoutLocale] === false || gr[pathKey] === false)\n if (isUnlocalized && localeFromPath !== null) {\n return normalizePathForCompare(pathWithoutLocale)\n }\n if (isUnlocalized && localeFromPath === null) {\n return null\n }\n const expectedPath = this.buildPathWithPrefix(pathWithoutLocale, detectedLocale)\n const currentPathOnly = getCleanPath(currentPath)\n if (localeFromPath === detectedLocale && isSamePath(currentPathOnly, expectedPath)) {\n return null\n }\n return expectedPath\n }\n\n private buildPathWithPrefix(pathWithoutLocale: string, locale: string): string {\n const resolved = this.resolvePathForLocale(pathWithoutLocale, locale)\n if (resolved === '/' || resolved === '') {\n return `/${locale}`\n }\n const prefix = `/${locale}`\n const withSlash = resolved.startsWith('/') ? resolved : `/${resolved}`\n return cleanDoubleSlashes(prefix + withSlash)\n }\n}\n\n/** Alias for Nuxt alias consumption: only this strategy is bundled when importing from #i18n-strategy. */\nexport { PrefixPathStrategy as Strategy }\n"],"names":["PrefixPathStrategy","BasePathStrategy","path","locale","_isCustom","joinUrl","normalizePath","baseName","route","targetLocale","segment","normalized","cleanDoubleSlashes","localeFromPath","currentPath","detectedLocale","pathWithoutLocale","gr","pathKey","withoutLeadingSlash","isUnlocalized","normalizePathForCompare","expectedPath","currentPathOnly","getCleanPath","isSamePath","resolved","prefix","withSlash"],"mappings":"gIAKO,MAAMA,UAA2BC,EAAAA,gBAAiB,CAC7C,mBAAmBC,EAAcC,EAAgBC,EAA4B,CACrF,OAAOC,UAAQF,EAAQG,EAAAA,cAAcJ,CAAI,CAAC,CAC5C,CAEU,wBAAwBK,EAAkBJ,EAAwB,CAC1E,OAAO,KAAK,mBAAmBI,EAAUJ,CAAM,CACjD,CAES,iBAAiBK,EAA0BC,EAAqC,CACvF,MAAMC,EAAU,KAAK,qBAAqBF,EAAOC,CAAY,EAC7D,GAAI,CAACC,EAAS,OAAO,KACrB,MAAMC,EAAaD,EAAQ,WAAW,GAAG,EAAIA,EAAU,IAAIA,CAAO,GAClE,OAAOE,EAAAA,mBAAmB,IAAIH,CAAY,GAAGE,CAAU,EAAE,CAC3D,CAEA,sBAAsBT,EAA6B,CACjD,KAAM,CAAE,eAAAW,CAAA,EAAmB,KAAK,qBAAqBX,CAAI,EACzD,OAAOW,CACT,CAEA,YAAYC,EAAqBC,EAAuC,CACtE,KAAM,CAAE,kBAAAC,EAAmB,eAAAH,CAAA,EAAmB,KAAK,qBAAqBC,CAAW,EAC7EG,EAAK,KAAK,IAAI,mBACdC,EAAUF,IAAsB,IAAM,IAAMG,EAAAA,oBAAoBH,CAAiB,EACjFI,EAAgBH,IAAOA,EAAGD,CAAiB,IAAM,IAASC,EAAGC,CAAO,IAAM,IAChF,GAAIE,GAAiBP,IAAmB,KACtC,OAAOQ,EAAAA,wBAAwBL,CAAiB,EAElD,GAAII,GAAiBP,IAAmB,KACtC,OAAO,KAET,MAAMS,EAAe,KAAK,oBAAoBN,EAAmBD,CAAc,EACzEQ,EAAkBC,EAAAA,aAAaV,CAAW,EAChD,OAAID,IAAmBE,GAAkBU,EAAAA,WAAWF,EAAiBD,CAAY,EACxE,KAEFA,CACT,CAEQ,oBAAoBN,EAA2Bb,EAAwB,CAC7E,MAAMuB,EAAW,KAAK,qBAAqBV,EAAmBb,CAAM,EACpE,GAAIuB,IAAa,KAAOA,IAAa,GACnC,MAAO,IAAIvB,CAAM,GAEnB,MAAMwB,EAAS,IAAIxB,CAAM,GACnByB,EAAYF,EAAS,WAAW,GAAG,EAAIA,EAAW,IAAIA,CAAQ,GACpE,OAAOd,EAAAA,mBAAmBe,EAASC,CAAS,CAC9C,CACF"}
|
|
1
|
+
{"version":3,"file":"prefix-strategy.cjs","sources":["../src/strategies/prefix.ts"],"sourcesContent":["import type { ResolvedRouteLike } from '../core/types'\nimport { BasePathStrategy } from './base-strategy'\nimport { cleanDoubleSlashes, isSamePath, withoutLeadingSlash } from 'ufo'\nimport { getCleanPath, joinUrl, normalizePath, normalizePathForCompare } from '../utils/path'\n\nexport class PrefixPathStrategy extends BasePathStrategy {\n protected buildLocalizedPath(path: string, locale: string, _isCustom: boolean): string {\n return joinUrl(locale, normalizePath(path))\n }\n\n protected buildLocalizedRouteName(baseName: string, locale: string): string {\n return this.buildLocalizedName(baseName, locale)\n }\n\n override 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 return cleanDoubleSlashes(`/${targetLocale}${normalized}`)\n }\n\n resolveLocaleFromPath(path: string): string | null {\n const { localeFromPath } = this.getPathWithoutLocale(path)\n return localeFromPath\n }\n\n getRedirect(currentPath: string, detectedLocale: string): string | null {\n const { pathWithoutLocale, localeFromPath } = this.getPathWithoutLocale(currentPath)\n const gr = this.ctx.globalLocaleRoutes\n const pathKey = pathWithoutLocale === '/' ? '/' : withoutLeadingSlash(pathWithoutLocale)\n const isUnlocalized = gr && (gr[pathWithoutLocale] === false || gr[pathKey] === false)\n if (isUnlocalized && localeFromPath !== null) {\n return normalizePathForCompare(pathWithoutLocale)\n }\n if (isUnlocalized && localeFromPath === null) {\n return null\n }\n const expectedPath = this.buildPathWithPrefix(pathWithoutLocale, detectedLocale)\n const currentPathOnly = getCleanPath(currentPath)\n if (localeFromPath === detectedLocale && isSamePath(currentPathOnly, expectedPath)) {\n return null\n }\n return expectedPath\n }\n\n private buildPathWithPrefix(pathWithoutLocale: string, locale: string): string {\n const resolved = this.resolvePathForLocale(pathWithoutLocale, locale)\n if (resolved === '/' || resolved === '') {\n return `/${locale}`\n }\n const prefix = `/${locale}`\n const withSlash = resolved.startsWith('/') ? resolved : `/${resolved}`\n return cleanDoubleSlashes(prefix + withSlash)\n }\n\n /**\n * Formats path for router.resolve.\n * prefix: always add locale prefix.\n */\n formatPathForResolve(path: string, fromLocale: string, _toLocale: string): string {\n return `/${fromLocale}${path}`\n }\n\n /**\n * prefix strategy: redirect only if URL has no locale prefix.\n * Does NOT redirect if user explicitly navigates to a locale path.\n * Uses custom paths from globalLocaleRoutes when available.\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 (uses globalLocaleRoutes)\n const customPath = this.resolvePathForLocale(pathWithoutLocale, preferredLocale)\n let targetPath = cleanDoubleSlashes(`/${preferredLocale}${customPath.startsWith('/') ? customPath : `/${customPath}`}`)\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: only this strategy is bundled when importing from #i18n-strategy. */\nexport { PrefixPathStrategy as Strategy }\n"],"names":["PrefixPathStrategy","BasePathStrategy","path","locale","_isCustom","joinUrl","normalizePath","baseName","route","targetLocale","segment","normalized","cleanDoubleSlashes","localeFromPath","currentPath","detectedLocale","pathWithoutLocale","gr","pathKey","withoutLeadingSlash","isUnlocalized","normalizePathForCompare","expectedPath","currentPathOnly","getCleanPath","isSamePath","resolved","prefix","withSlash","fromLocale","_toLocale","preferredLocale","customPath","targetPath","currentClean"],"mappings":"gIAKO,MAAMA,UAA2BC,EAAAA,gBAAiB,CAC7C,mBAAmBC,EAAcC,EAAgBC,EAA4B,CACrF,OAAOC,UAAQF,EAAQG,EAAAA,cAAcJ,CAAI,CAAC,CAC5C,CAEU,wBAAwBK,EAAkBJ,EAAwB,CAC1E,OAAO,KAAK,mBAAmBI,EAAUJ,CAAM,CACjD,CAES,iBAAiBK,EAA0BC,EAAqC,CACvF,MAAMC,EAAU,KAAK,qBAAqBF,EAAOC,CAAY,EAC7D,GAAI,CAACC,EAAS,OAAO,KACrB,MAAMC,EAAaD,EAAQ,WAAW,GAAG,EAAIA,EAAU,IAAIA,CAAO,GAClE,OAAOE,EAAAA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,oBAAoBH,CAAiB,EAMvF,GALIC,IAAOA,EAAGD,CAAiB,IAAM,IAASC,EAAGC,CAAO,IAAM,KAK1DL,IAAmB,KAAM,OAAO,KAGpC,MAAMmB,EAAa,KAAK,qBAAqBhB,EAAmBe,CAAe,EAC/E,IAAIE,EAAarB,EAAAA,mBAAmB,IAAImB,CAAe,GAAGC,EAAW,WAAW,GAAG,EAAIA,EAAa,IAAIA,CAAU,EAAE,EAAE,EAGlHC,IAAe,KAAOA,EAAW,SAAS,GAAG,IAC/CA,EAAaA,EAAW,MAAM,EAAG,EAAE,GAIrC,MAAMC,EAAeV,EAAAA,aAAaV,CAAW,EAC7C,OAAIW,aAAWS,EAAcD,CAAU,EAAU,KAE1CA,CACT,CACF"}
|
|
@@ -15,10 +15,14 @@ declare abstract class BasePathStrategy implements PathStrategy {
|
|
|
15
15
|
getRouteLocales(): PathStrategyContext['routeLocales'];
|
|
16
16
|
getRoutesLocaleLinks(): PathStrategyContext['routesLocaleLinks'];
|
|
17
17
|
getNoPrefixRedirect(): boolean | undefined;
|
|
18
|
-
/**
|
|
18
|
+
/**
|
|
19
|
+
* Returns base route name without locale prefix/suffix.
|
|
20
|
+
* @param route - Route object
|
|
21
|
+
* @param locale - Optional locale to strip suffix for (if not provided, tries all locales)
|
|
22
|
+
*/
|
|
23
|
+
getRouteBaseName(route: RouteLike, locale?: string): string | null;
|
|
24
|
+
/** Alias for internal use - strips localization prefix/suffix for specific locale. */
|
|
19
25
|
protected getBaseRouteName(route: RouteLike, locale: string): string | null;
|
|
20
|
-
/** Returns the base route name (without localized prefix/suffix) by trying all locales. */
|
|
21
|
-
getRouteBaseName(route: RouteLike): string | null;
|
|
22
26
|
/** Resolves target path for a locale, checking globalLocaleRoutes first. */
|
|
23
27
|
protected resolvePathForLocale(path: string, targetLocale: string): string;
|
|
24
28
|
protected buildLocalizedName(baseName: string, locale: string): string;
|
|
@@ -70,6 +74,17 @@ declare abstract class BasePathStrategy implements PathStrategy {
|
|
|
70
74
|
* Use in middleware: strategy.getRedirect(to.fullPath, detectedLocale)
|
|
71
75
|
*/
|
|
72
76
|
abstract getRedirect(currentPath: string, targetLocale: string): string | null;
|
|
77
|
+
/**
|
|
78
|
+
* Returns path to redirect to for client-side navigation based on preferred locale.
|
|
79
|
+
* Returns null if no redirect needed. Each strategy implements its own logic.
|
|
80
|
+
*/
|
|
81
|
+
abstract getClientRedirect(currentPath: string, preferredLocale: string): string | null;
|
|
82
|
+
/**
|
|
83
|
+
* Checks if the current path should return 404.
|
|
84
|
+
* Returns error message if 404 should be returned, null otherwise.
|
|
85
|
+
* Base implementation checks unlocalized routes and routeLocales restrictions.
|
|
86
|
+
*/
|
|
87
|
+
shouldReturn404(currentPath: string): string | null;
|
|
73
88
|
/**
|
|
74
89
|
* Builds SEO attributes (canonical + hreflangs) from current route.
|
|
75
90
|
* Respects routeLocales: only allowed locales for this route get an hreflang entry.
|
|
@@ -104,10 +119,32 @@ declare abstract class BasePathStrategy implements PathStrategy {
|
|
|
104
119
|
* Strategies with different logic (e.g. prefix-except-default) override this method.
|
|
105
120
|
*/
|
|
106
121
|
protected resolveLocaleRoute(targetLocale: string, normalized: NormalizedRouteInput, _currentRoute?: ResolvedRouteLike): RouteLike | string;
|
|
122
|
+
/**
|
|
123
|
+
* Extracts locale from URL path by checking the first path segment.
|
|
124
|
+
*/
|
|
125
|
+
private extractLocaleFromPath;
|
|
126
|
+
/**
|
|
127
|
+
* Determines current locale from route, considering hashMode, noPrefix, prefix_and_default at /, etc.
|
|
128
|
+
*/
|
|
129
|
+
getCurrentLocale(route: ResolvedRouteLike, getDefaultLocale?: () => string | null | undefined): string;
|
|
130
|
+
/**
|
|
131
|
+
* Returns the route name for plugin translation loading.
|
|
132
|
+
* If disablePageLocales is true, returns 'general'.
|
|
133
|
+
*/
|
|
134
|
+
getPluginRouteName(route: ResolvedRouteLike, locale: string): string;
|
|
135
|
+
/**
|
|
136
|
+
* Returns displayName of the current locale, or null if not found.
|
|
137
|
+
*/
|
|
138
|
+
getCurrentLocaleName(route: ResolvedRouteLike): string | null;
|
|
139
|
+
/**
|
|
140
|
+
* Formats path for router.resolve based on strategy.
|
|
141
|
+
* Each strategy should override this with its own logic.
|
|
142
|
+
*/
|
|
143
|
+
abstract formatPathForResolve(path: string, fromLocale: string, toLocale: string): string;
|
|
107
144
|
}
|
|
108
145
|
|
|
109
146
|
/** Custom path rules: route key -> locale -> path segment. false = unlocalized route. */
|
|
110
|
-
declare type GlobalLocaleRoutes = Record<string, Record<string, string> | false>;
|
|
147
|
+
declare type GlobalLocaleRoutes = Record<string, Record<string, string> | false | boolean>;
|
|
111
148
|
|
|
112
149
|
declare interface HreflangTag {
|
|
113
150
|
rel: 'alternate';
|
|
@@ -156,6 +193,18 @@ declare interface PathStrategy {
|
|
|
156
193
|
* Use in middleware: const redirectPath = strategy.getRedirect(to.fullPath, detectedLocale)
|
|
157
194
|
*/
|
|
158
195
|
getRedirect(currentPath: string, targetLocale: string): string | null;
|
|
196
|
+
/**
|
|
197
|
+
* Checks if the current path should return 404.
|
|
198
|
+
* Returns error message if 404 should be returned, null otherwise.
|
|
199
|
+
* Checks: invalid locale prefix, unlocalized routes with prefix, route locale restrictions.
|
|
200
|
+
*/
|
|
201
|
+
shouldReturn404(currentPath: string): string | null;
|
|
202
|
+
/**
|
|
203
|
+
* Returns path to redirect to for client-side navigation based on preferred locale.
|
|
204
|
+
* Returns null if no redirect needed.
|
|
205
|
+
* Used by client redirect plugin - each strategy implements its own logic.
|
|
206
|
+
*/
|
|
207
|
+
getClientRedirect(currentPath: string, preferredLocale: string): string | null;
|
|
159
208
|
/**
|
|
160
209
|
* Returns SEO attributes (canonical, hreflangs) for useHead.
|
|
161
210
|
*/
|
|
@@ -172,6 +221,35 @@ declare interface PathStrategy {
|
|
|
172
221
|
getRouteLocales(): Record<string, string[]> | undefined;
|
|
173
222
|
getRoutesLocaleLinks(): Record<string, string> | undefined;
|
|
174
223
|
getNoPrefixRedirect(): boolean | undefined;
|
|
224
|
+
/**
|
|
225
|
+
* Determines current locale from route, considering hashMode, noPrefix, etc.
|
|
226
|
+
* @param route - Current route object
|
|
227
|
+
* @param getDefaultLocale - Optional getter for locale state (for hashMode/noPrefix)
|
|
228
|
+
*/
|
|
229
|
+
getCurrentLocale(route: ResolvedRouteLike, getDefaultLocale?: () => string | null | undefined): string;
|
|
230
|
+
/**
|
|
231
|
+
* Returns the route name for plugin translation loading.
|
|
232
|
+
* If disablePageLocales is true, returns 'general'.
|
|
233
|
+
*/
|
|
234
|
+
getPluginRouteName(route: ResolvedRouteLike, locale: string): string;
|
|
235
|
+
/**
|
|
236
|
+
* Returns base route name without locale prefix/suffix.
|
|
237
|
+
* @param route - Route object
|
|
238
|
+
* @param locale - Optional locale to strip suffix for (if not provided, tries all locales)
|
|
239
|
+
*/
|
|
240
|
+
getRouteBaseName(route: RouteLike, locale?: string): string | null;
|
|
241
|
+
/**
|
|
242
|
+
* Returns displayName of the current locale, or null if not found.
|
|
243
|
+
*/
|
|
244
|
+
getCurrentLocaleName(route: ResolvedRouteLike): string | null;
|
|
245
|
+
/**
|
|
246
|
+
* Formats path for router.resolve based on strategy.
|
|
247
|
+
* Returns path with or without locale prefix depending on strategy.
|
|
248
|
+
* @param path - Original path (e.g. '/about')
|
|
249
|
+
* @param fromLocale - Current locale
|
|
250
|
+
* @param toLocale - Target locale
|
|
251
|
+
*/
|
|
252
|
+
formatPathForResolve(path: string, fromLocale: string, toLocale: string): string;
|
|
175
253
|
}
|
|
176
254
|
|
|
177
255
|
declare interface PathStrategyContext {
|
|
@@ -186,6 +264,10 @@ declare interface PathStrategyContext {
|
|
|
186
264
|
noPrefixRedirect?: boolean;
|
|
187
265
|
debug?: boolean;
|
|
188
266
|
router: RouterAdapter;
|
|
267
|
+
/** Hash mode: locale stored in hash, no prefix in path */
|
|
268
|
+
hashMode?: boolean;
|
|
269
|
+
/** When true, all pages use only global translations (no page-specific loading) */
|
|
270
|
+
disablePageLocales?: boolean;
|
|
189
271
|
}
|
|
190
272
|
|
|
191
273
|
declare class PrefixPathStrategy extends BasePathStrategy {
|
|
@@ -195,6 +277,17 @@ declare class PrefixPathStrategy extends BasePathStrategy {
|
|
|
195
277
|
resolveLocaleFromPath(path: string): string | null;
|
|
196
278
|
getRedirect(currentPath: string, detectedLocale: string): string | null;
|
|
197
279
|
private buildPathWithPrefix;
|
|
280
|
+
/**
|
|
281
|
+
* Formats path for router.resolve.
|
|
282
|
+
* prefix: always add locale prefix.
|
|
283
|
+
*/
|
|
284
|
+
formatPathForResolve(path: string, fromLocale: string, _toLocale: string): string;
|
|
285
|
+
/**
|
|
286
|
+
* prefix strategy: redirect only if URL has no locale prefix.
|
|
287
|
+
* Does NOT redirect if user explicitly navigates to a locale path.
|
|
288
|
+
* Uses custom paths from globalLocaleRoutes when available.
|
|
289
|
+
*/
|
|
290
|
+
getClientRedirect(currentPath: string, preferredLocale: string): string | null;
|
|
198
291
|
}
|
|
199
292
|
export { PrefixPathStrategy }
|
|
200
293
|
export { PrefixPathStrategy as Strategy }
|
package/dist/prefix-strategy.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { B as
|
|
2
|
-
class
|
|
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-PVpkf05w.js";
|
|
2
|
+
class $ extends g {
|
|
3
3
|
buildLocalizedPath(a, e, t) {
|
|
4
|
-
return
|
|
4
|
+
return m(e, f(a));
|
|
5
5
|
}
|
|
6
6
|
buildLocalizedRouteName(a, e) {
|
|
7
7
|
return this.buildLocalizedName(a, e);
|
|
@@ -10,31 +10,52 @@ class S extends u {
|
|
|
10
10
|
const t = this.getCustomPathSegment(a, e);
|
|
11
11
|
if (!t) return null;
|
|
12
12
|
const s = t.startsWith("/") ? t : `/${t}`;
|
|
13
|
-
return
|
|
13
|
+
return h(`/${e}${s}`);
|
|
14
14
|
}
|
|
15
15
|
resolveLocaleFromPath(a) {
|
|
16
16
|
const { localeFromPath: e } = this.getPathWithoutLocale(a);
|
|
17
17
|
return e;
|
|
18
18
|
}
|
|
19
19
|
getRedirect(a, e) {
|
|
20
|
-
const { pathWithoutLocale: t, localeFromPath: s } = this.getPathWithoutLocale(a),
|
|
21
|
-
if (
|
|
22
|
-
return
|
|
23
|
-
if (
|
|
20
|
+
const { pathWithoutLocale: t, localeFromPath: s } = this.getPathWithoutLocale(a), o = this.ctx.globalLocaleRoutes, i = t === "/" ? "/" : u(t), r = o && (o[t] === !1 || o[i] === !1);
|
|
21
|
+
if (r && s !== null)
|
|
22
|
+
return d(t);
|
|
23
|
+
if (r && s === null)
|
|
24
24
|
return null;
|
|
25
|
-
const
|
|
26
|
-
return s === e &&
|
|
25
|
+
const l = this.buildPathWithPrefix(t, e), n = c(a);
|
|
26
|
+
return s === e && P(n, l) ? null : l;
|
|
27
27
|
}
|
|
28
28
|
buildPathWithPrefix(a, e) {
|
|
29
29
|
const t = this.resolvePathForLocale(a, e);
|
|
30
30
|
if (t === "/" || t === "")
|
|
31
31
|
return `/${e}`;
|
|
32
|
-
const s = `/${e}`,
|
|
33
|
-
return
|
|
32
|
+
const s = `/${e}`, o = t.startsWith("/") ? t : `/${t}`;
|
|
33
|
+
return h(s + o);
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Formats path for router.resolve.
|
|
37
|
+
* prefix: always add locale prefix.
|
|
38
|
+
*/
|
|
39
|
+
formatPathForResolve(a, e, t) {
|
|
40
|
+
return `/${e}${a}`;
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* prefix strategy: redirect only if URL has no locale prefix.
|
|
44
|
+
* Does NOT redirect if user explicitly navigates to a locale path.
|
|
45
|
+
* Uses custom paths from globalLocaleRoutes when available.
|
|
46
|
+
*/
|
|
47
|
+
getClientRedirect(a, e) {
|
|
48
|
+
const { pathWithoutLocale: t, localeFromPath: s } = this.getPathWithoutLocale(a), o = this.ctx.globalLocaleRoutes, i = t === "/" ? "/" : u(t);
|
|
49
|
+
if (o && (o[t] === !1 || o[i] === !1) || s !== null) return null;
|
|
50
|
+
const r = this.resolvePathForLocale(t, e);
|
|
51
|
+
let l = h(`/${e}${r.startsWith("/") ? r : `/${r}`}`);
|
|
52
|
+
l !== "/" && l.endsWith("/") && (l = l.slice(0, -1));
|
|
53
|
+
const n = c(a);
|
|
54
|
+
return P(n, l) ? null : l;
|
|
34
55
|
}
|
|
35
56
|
}
|
|
36
57
|
export {
|
|
37
|
-
|
|
38
|
-
|
|
58
|
+
$ as PrefixPathStrategy,
|
|
59
|
+
$ as Strategy
|
|
39
60
|
};
|
|
40
61
|
//# sourceMappingURL=prefix-strategy.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"prefix-strategy.mjs","sources":["../src/strategies/prefix.ts"],"sourcesContent":["import type { ResolvedRouteLike } from '../core/types'\nimport { BasePathStrategy } from './base-strategy'\nimport { cleanDoubleSlashes, isSamePath, withoutLeadingSlash } from 'ufo'\nimport { getCleanPath, joinUrl, normalizePath, normalizePathForCompare } from '../utils/path'\n\nexport class PrefixPathStrategy extends BasePathStrategy {\n protected buildLocalizedPath(path: string, locale: string, _isCustom: boolean): string {\n return joinUrl(locale, normalizePath(path))\n }\n\n protected buildLocalizedRouteName(baseName: string, locale: string): string {\n return this.buildLocalizedName(baseName, locale)\n }\n\n override 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 return cleanDoubleSlashes(`/${targetLocale}${normalized}`)\n }\n\n resolveLocaleFromPath(path: string): string | null {\n const { localeFromPath } = this.getPathWithoutLocale(path)\n return localeFromPath\n }\n\n getRedirect(currentPath: string, detectedLocale: string): string | null {\n const { pathWithoutLocale, localeFromPath } = this.getPathWithoutLocale(currentPath)\n const gr = this.ctx.globalLocaleRoutes\n const pathKey = pathWithoutLocale === '/' ? '/' : withoutLeadingSlash(pathWithoutLocale)\n const isUnlocalized = gr && (gr[pathWithoutLocale] === false || gr[pathKey] === false)\n if (isUnlocalized && localeFromPath !== null) {\n return normalizePathForCompare(pathWithoutLocale)\n }\n if (isUnlocalized && localeFromPath === null) {\n return null\n }\n const expectedPath = this.buildPathWithPrefix(pathWithoutLocale, detectedLocale)\n const currentPathOnly = getCleanPath(currentPath)\n if (localeFromPath === detectedLocale && isSamePath(currentPathOnly, expectedPath)) {\n return null\n }\n return expectedPath\n }\n\n private buildPathWithPrefix(pathWithoutLocale: string, locale: string): string {\n const resolved = this.resolvePathForLocale(pathWithoutLocale, locale)\n if (resolved === '/' || resolved === '') {\n return `/${locale}`\n }\n const prefix = `/${locale}`\n const withSlash = resolved.startsWith('/') ? resolved : `/${resolved}`\n return cleanDoubleSlashes(prefix + withSlash)\n }\n}\n\n/** Alias for Nuxt alias consumption: only this strategy is bundled when importing from #i18n-strategy. */\nexport { PrefixPathStrategy as Strategy }\n"],"names":["PrefixPathStrategy","BasePathStrategy","path","locale","_isCustom","joinUrl","normalizePath","baseName","route","targetLocale","segment","normalized","cleanDoubleSlashes","localeFromPath","currentPath","detectedLocale","pathWithoutLocale","gr","pathKey","withoutLeadingSlash","isUnlocalized","normalizePathForCompare","expectedPath","currentPathOnly","getCleanPath","isSamePath","resolved","prefix","withSlash"],"mappings":";AAKO,MAAMA,UAA2BC,EAAiB;AAAA,EAC7C,mBAAmBC,GAAcC,GAAgBC,GAA4B;AACrF,WAAOC,EAAQF,GAAQG,EAAcJ,CAAI,CAAC;AAAA,EAC5C;AAAA,EAEU,wBAAwBK,GAAkBJ,GAAwB;AAC1E,WAAO,KAAK,mBAAmBI,GAAUJ,CAAM;AAAA,EACjD;AAAA,EAES,iBAAiBK,GAA0BC,GAAqC;AACvF,UAAMC,IAAU,KAAK,qBAAqBF,GAAOC,CAAY;AAC7D,QAAI,CAACC,EAAS,QAAO;AACrB,UAAMC,IAAaD,EAAQ,WAAW,GAAG,IAAIA,IAAU,IAAIA,CAAO;AAClE,WAAOE,EAAmB,IAAIH,CAAY,GAAGE,CAAU,EAAE;AAAA,EAC3D;AAAA,EAEA,sBAAsBT,GAA6B;AACjD,UAAM,EAAE,gBAAAW,EAAA,IAAmB,KAAK,qBAAqBX,CAAI;AACzD,WAAOW;AAAA,EACT;AAAA,EAEA,YAAYC,GAAqBC,GAAuC;AACtE,UAAM,EAAE,mBAAAC,GAAmB,gBAAAH,EAAA,IAAmB,KAAK,qBAAqBC,CAAW,GAC7EG,IAAK,KAAK,IAAI,oBACdC,IAAUF,MAAsB,MAAM,MAAMG,EAAoBH,CAAiB,GACjFI,IAAgBH,MAAOA,EAAGD,CAAiB,MAAM,MAASC,EAAGC,CAAO,MAAM;AAChF,QAAIE,KAAiBP,MAAmB;AACtC,aAAOQ,EAAwBL,CAAiB;AAElD,QAAII,KAAiBP,MAAmB;AACtC,aAAO;AAET,UAAMS,IAAe,KAAK,oBAAoBN,GAAmBD,CAAc,GACzEQ,IAAkBC,EAAaV,CAAW;AAChD,WAAID,MAAmBE,KAAkBU,EAAWF,GAAiBD,CAAY,IACxE,OAEFA;AAAA,EACT;AAAA,EAEQ,oBAAoBN,GAA2Bb,GAAwB;AAC7E,UAAMuB,IAAW,KAAK,qBAAqBV,GAAmBb,CAAM;AACpE,QAAIuB,MAAa,OAAOA,MAAa;AACnC,aAAO,IAAIvB,CAAM;AAEnB,UAAMwB,IAAS,IAAIxB,CAAM,IACnByB,IAAYF,EAAS,WAAW,GAAG,IAAIA,IAAW,IAAIA,CAAQ;AACpE,WAAOd,EAAmBe,IAASC,CAAS;AAAA,EAC9C;AACF;"}
|
|
1
|
+
{"version":3,"file":"prefix-strategy.mjs","sources":["../src/strategies/prefix.ts"],"sourcesContent":["import type { ResolvedRouteLike } from '../core/types'\nimport { BasePathStrategy } from './base-strategy'\nimport { cleanDoubleSlashes, isSamePath, withoutLeadingSlash } from 'ufo'\nimport { getCleanPath, joinUrl, normalizePath, normalizePathForCompare } from '../utils/path'\n\nexport class PrefixPathStrategy extends BasePathStrategy {\n protected buildLocalizedPath(path: string, locale: string, _isCustom: boolean): string {\n return joinUrl(locale, normalizePath(path))\n }\n\n protected buildLocalizedRouteName(baseName: string, locale: string): string {\n return this.buildLocalizedName(baseName, locale)\n }\n\n override 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 return cleanDoubleSlashes(`/${targetLocale}${normalized}`)\n }\n\n resolveLocaleFromPath(path: string): string | null {\n const { localeFromPath } = this.getPathWithoutLocale(path)\n return localeFromPath\n }\n\n getRedirect(currentPath: string, detectedLocale: string): string | null {\n const { pathWithoutLocale, localeFromPath } = this.getPathWithoutLocale(currentPath)\n const gr = this.ctx.globalLocaleRoutes\n const pathKey = pathWithoutLocale === '/' ? '/' : withoutLeadingSlash(pathWithoutLocale)\n const isUnlocalized = gr && (gr[pathWithoutLocale] === false || gr[pathKey] === false)\n if (isUnlocalized && localeFromPath !== null) {\n return normalizePathForCompare(pathWithoutLocale)\n }\n if (isUnlocalized && localeFromPath === null) {\n return null\n }\n const expectedPath = this.buildPathWithPrefix(pathWithoutLocale, detectedLocale)\n const currentPathOnly = getCleanPath(currentPath)\n if (localeFromPath === detectedLocale && isSamePath(currentPathOnly, expectedPath)) {\n return null\n }\n return expectedPath\n }\n\n private buildPathWithPrefix(pathWithoutLocale: string, locale: string): string {\n const resolved = this.resolvePathForLocale(pathWithoutLocale, locale)\n if (resolved === '/' || resolved === '') {\n return `/${locale}`\n }\n const prefix = `/${locale}`\n const withSlash = resolved.startsWith('/') ? resolved : `/${resolved}`\n return cleanDoubleSlashes(prefix + withSlash)\n }\n\n /**\n * Formats path for router.resolve.\n * prefix: always add locale prefix.\n */\n formatPathForResolve(path: string, fromLocale: string, _toLocale: string): string {\n return `/${fromLocale}${path}`\n }\n\n /**\n * prefix strategy: redirect only if URL has no locale prefix.\n * Does NOT redirect if user explicitly navigates to a locale path.\n * Uses custom paths from globalLocaleRoutes when available.\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 (uses globalLocaleRoutes)\n const customPath = this.resolvePathForLocale(pathWithoutLocale, preferredLocale)\n let targetPath = cleanDoubleSlashes(`/${preferredLocale}${customPath.startsWith('/') ? customPath : `/${customPath}`}`)\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: only this strategy is bundled when importing from #i18n-strategy. */\nexport { PrefixPathStrategy as Strategy }\n"],"names":["PrefixPathStrategy","BasePathStrategy","path","locale","_isCustom","joinUrl","normalizePath","baseName","route","targetLocale","segment","normalized","cleanDoubleSlashes","localeFromPath","currentPath","detectedLocale","pathWithoutLocale","gr","pathKey","withoutLeadingSlash","isUnlocalized","normalizePathForCompare","expectedPath","currentPathOnly","getCleanPath","isSamePath","resolved","prefix","withSlash","fromLocale","_toLocale","preferredLocale","customPath","targetPath","currentClean"],"mappings":";AAKO,MAAMA,UAA2BC,EAAiB;AAAA,EAC7C,mBAAmBC,GAAcC,GAAgBC,GAA4B;AACrF,WAAOC,EAAQF,GAAQG,EAAcJ,CAAI,CAAC;AAAA,EAC5C;AAAA,EAEU,wBAAwBK,GAAkBJ,GAAwB;AAC1E,WAAO,KAAK,mBAAmBI,GAAUJ,CAAM;AAAA,EACjD;AA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B;AAChF,WAAO,IAAID,CAAU,GAAG3B,CAAI;AAAA,EAC9B;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOA,kBAAkBY,GAAqBiB,GAAwC;AAC7E,UAAM,EAAE,mBAAAf,GAAmB,gBAAAH,EAAA,IAAmB,KAAK,qBAAqBC,CAAW,GAG7EG,IAAK,KAAK,IAAI,oBACdC,IAAUF,MAAsB,MAAM,MAAMG,EAAoBH,CAAiB;AAMvF,QALIC,MAAOA,EAAGD,CAAiB,MAAM,MAASC,EAAGC,CAAO,MAAM,OAK1DL,MAAmB,KAAM,QAAO;AAGpC,UAAMmB,IAAa,KAAK,qBAAqBhB,GAAmBe,CAAe;AAC/E,QAAIE,IAAarB,EAAmB,IAAImB,CAAe,GAAGC,EAAW,WAAW,GAAG,IAAIA,IAAa,IAAIA,CAAU,EAAE,EAAE;AAGtH,IAAIC,MAAe,OAAOA,EAAW,SAAS,GAAG,MAC/CA,IAAaA,EAAW,MAAM,GAAG,EAAE;AAIrC,UAAMC,IAAeV,EAAaV,CAAW;AAC7C,WAAIW,EAAWS,GAAcD,CAAU,IAAU,OAE1CA;AAAA,EACT;AACF;"}
|
package/dist/types.d.ts
CHANGED
|
@@ -3,7 +3,7 @@ import { Locale } from '@i18n-micro/types';
|
|
|
3
3
|
import { Strategies } from '@i18n-micro/types';
|
|
4
4
|
|
|
5
5
|
/** Custom path rules: route key -> locale -> path segment. false = unlocalized route. */
|
|
6
|
-
declare type GlobalLocaleRoutes = Record<string, Record<string, string> | false>;
|
|
6
|
+
declare type GlobalLocaleRoutes = Record<string, Record<string, string> | false | boolean>;
|
|
7
7
|
|
|
8
8
|
export declare interface HreflangTag {
|
|
9
9
|
rel: 'alternate';
|
|
@@ -41,6 +41,18 @@ export declare interface PathStrategy {
|
|
|
41
41
|
* Use in middleware: const redirectPath = strategy.getRedirect(to.fullPath, detectedLocale)
|
|
42
42
|
*/
|
|
43
43
|
getRedirect(currentPath: string, targetLocale: string): string | null;
|
|
44
|
+
/**
|
|
45
|
+
* Checks if the current path should return 404.
|
|
46
|
+
* Returns error message if 404 should be returned, null otherwise.
|
|
47
|
+
* Checks: invalid locale prefix, unlocalized routes with prefix, route locale restrictions.
|
|
48
|
+
*/
|
|
49
|
+
shouldReturn404(currentPath: string): string | null;
|
|
50
|
+
/**
|
|
51
|
+
* Returns path to redirect to for client-side navigation based on preferred locale.
|
|
52
|
+
* Returns null if no redirect needed.
|
|
53
|
+
* Used by client redirect plugin - each strategy implements its own logic.
|
|
54
|
+
*/
|
|
55
|
+
getClientRedirect(currentPath: string, preferredLocale: string): string | null;
|
|
44
56
|
/**
|
|
45
57
|
* Returns SEO attributes (canonical, hreflangs) for useHead.
|
|
46
58
|
*/
|
|
@@ -57,6 +69,35 @@ export declare interface PathStrategy {
|
|
|
57
69
|
getRouteLocales(): Record<string, string[]> | undefined;
|
|
58
70
|
getRoutesLocaleLinks(): Record<string, string> | undefined;
|
|
59
71
|
getNoPrefixRedirect(): boolean | undefined;
|
|
72
|
+
/**
|
|
73
|
+
* Determines current locale from route, considering hashMode, noPrefix, etc.
|
|
74
|
+
* @param route - Current route object
|
|
75
|
+
* @param getDefaultLocale - Optional getter for locale state (for hashMode/noPrefix)
|
|
76
|
+
*/
|
|
77
|
+
getCurrentLocale(route: ResolvedRouteLike, getDefaultLocale?: () => string | null | undefined): string;
|
|
78
|
+
/**
|
|
79
|
+
* Returns the route name for plugin translation loading.
|
|
80
|
+
* If disablePageLocales is true, returns 'general'.
|
|
81
|
+
*/
|
|
82
|
+
getPluginRouteName(route: ResolvedRouteLike, locale: string): string;
|
|
83
|
+
/**
|
|
84
|
+
* Returns base route name without locale prefix/suffix.
|
|
85
|
+
* @param route - Route object
|
|
86
|
+
* @param locale - Optional locale to strip suffix for (if not provided, tries all locales)
|
|
87
|
+
*/
|
|
88
|
+
getRouteBaseName(route: RouteLike, locale?: string): string | null;
|
|
89
|
+
/**
|
|
90
|
+
* Returns displayName of the current locale, or null if not found.
|
|
91
|
+
*/
|
|
92
|
+
getCurrentLocaleName(route: ResolvedRouteLike): string | null;
|
|
93
|
+
/**
|
|
94
|
+
* Formats path for router.resolve based on strategy.
|
|
95
|
+
* Returns path with or without locale prefix depending on strategy.
|
|
96
|
+
* @param path - Original path (e.g. '/about')
|
|
97
|
+
* @param fromLocale - Current locale
|
|
98
|
+
* @param toLocale - Target locale
|
|
99
|
+
*/
|
|
100
|
+
formatPathForResolve(path: string, fromLocale: string, toLocale: string): string;
|
|
60
101
|
}
|
|
61
102
|
|
|
62
103
|
export declare interface PathStrategyContext {
|
|
@@ -71,6 +112,10 @@ export declare interface PathStrategyContext {
|
|
|
71
112
|
noPrefixRedirect?: boolean;
|
|
72
113
|
debug?: boolean;
|
|
73
114
|
router: RouterAdapter;
|
|
115
|
+
/** Hash mode: locale stored in hash, no prefix in path */
|
|
116
|
+
hashMode?: boolean;
|
|
117
|
+
/** When true, all pages use only global translations (no page-specific loading) */
|
|
118
|
+
disablePageLocales?: boolean;
|
|
74
119
|
}
|
|
75
120
|
|
|
76
121
|
/** Resolved route (path and fullPath required). */
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@i18n-micro/path-strategy",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.1.1",
|
|
4
4
|
"description": "Shared strategy-based path and route name builder for Nuxt I18n Micro frontend routing.",
|
|
5
5
|
"repository": "s00d/nuxt-i18n-micro",
|
|
6
6
|
"license": "MIT",
|
|
@@ -53,7 +53,9 @@
|
|
|
53
53
|
"import": "./dist/types.mjs",
|
|
54
54
|
"require": "./dist/types.cjs",
|
|
55
55
|
"default": "./dist/types.mjs"
|
|
56
|
-
}
|
|
56
|
+
},
|
|
57
|
+
"./package.json": "./package.json",
|
|
58
|
+
"./dist/*": "./dist/*"
|
|
57
59
|
},
|
|
58
60
|
"publishConfig": {
|
|
59
61
|
"access": "public"
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
"use strict";const ht=/#/g,ct=/&/g,ut=/\//g,ft=/=/g,Q=/\+/g,Y=/%5e/gi,pt=/%60/gi,dt=/%7b/gi,mt=/%7c/gi,gt=/%7d/gi,Pt=/%20/gi;function Z(a){return encodeURI(""+a).replace(mt,"|")}function yt(a){return Z(a).replace(dt,"{").replace(gt,"}").replace(Y,"^")}function w(a){return Z(typeof a=="string"?a:JSON.stringify(a)).replace(Q,"%2B").replace(Pt,"+").replace(ht,"%23").replace(ct,"%26").replace(pt,"`").replace(Y,"^").replace(ut,"%2F")}function C(a){return w(a).replace(ft,"%3D")}function A(a=""){try{return decodeURIComponent(""+a)}catch{return""+a}}function Rt(a){return A(a.replace(Q," "))}function Lt(a){return A(a.replace(Q," "))}function bt(a=""){const t=Object.create(null);a[0]==="?"&&(a=a.slice(1));for(const e of a.split("&")){const o=e.match(/([^=]+)=?(.*)/)||[];if(o.length<2)continue;const s=Rt(o[1]);if(s==="__proto__"||s==="constructor")continue;const n=Lt(o[2]||"");t[s]===void 0?t[s]=n:Array.isArray(t[s])?t[s].push(n):t[s]=[t[s],n]}return t}function Nt(a,t){return(typeof t=="number"||typeof t=="boolean")&&(t=String(t)),t?Array.isArray(t)?t.map(e=>`${C(a)}=${w(e)}`).join("&"):`${C(a)}=${w(t)}`:C(a)}function xt(a){return Object.keys(a).filter(t=>a[t]!==void 0).map(t=>Nt(t,a[t])).filter(Boolean).join("&")}const zt=/^[\s\w\0+.-]{2,}:([/\\]{1,2})/,vt=/^[\s\w\0+.-]{2,}:([/\\]{2})?/,St=/^([/\\]\s*){2,}[^/\\]/,Bt=/^\.?\//;function W(a,t={}){return typeof t=="boolean"&&(t={acceptRelative:t}),t.strict?zt.test(a):vt.test(a)||(t.acceptRelative?St.test(a):!1)}function Ft(a="",t){return a.endsWith("/")}function v(a="",t){return(Ft(a)?a.slice(0,-1):a)||"/"}function At(a="",t){return a.endsWith("/")?a:a+"/"}function _(a=""){return a.startsWith("/")}function $(a=""){return(_(a)?a.slice(1):a)||"/"}function O(a=""){return _(a)?a:"/"+a}function T(a=""){return a.split("://").map(t=>t.replace(/\/{2,}/g,"/")).join("://")}function Wt(a,t){const e=H(a),o={...bt(e.search),...t};return e.search=xt(o),et(e)}function Ut(a){return!a||a==="/"}function Et(a){return a&&a!=="/"}function I(a,...t){let e=a||"";for(const o of t.filter(s=>Et(s)))if(e){const s=o.replace(Bt,"");e=At(e)+s}else e=o;return e}function _t(a,t){return A(v(a))===A(v(t))}function kt(a,t){if(!t||t==="#")return a;const e=H(a);return e.hash=t===""?"":"#"+yt(t),et(e)}const tt=Symbol.for("ufo:protocolRelative");function H(a="",t){const e=a.match(/^[\s\0]*(blob:|data:|javascript:|vbscript:)(.*)/i);if(e){const[,d,P=""]=e;return{protocol:d.toLowerCase(),pathname:P,href:d+P,auth:"",host:"",search:"",hash:""}}if(!W(a,{acceptRelative:!0}))return U(a);const[,o="",s,n=""]=a.replace(/\\/g,"/").match(/^[\s\0]*([\w+.-]{2,}:)?\/\/([^/@]+@)?(.*)/)||[];let[,r="",l=""]=n.match(/([^#/?]*)(.*)?/)||[];o==="file:"&&(l=l.replace(/\/(?=[A-Za-z]:)/,""));const{pathname:h,search:u,hash:m}=U(l);return{protocol:o.toLowerCase(),auth:s?s.slice(0,Math.max(0,s.length-1)):"",host:r,pathname:h,search:u,hash:m,[tt]:!o}}function U(a=""){const[t="",e="",o=""]=(a.match(/([^#?]*)(\?[^#]*)?(#.*)?/)||[]).splice(1);return{pathname:t,search:e,hash:o}}function et(a){const t=a.pathname||"",e=a.search?(a.search.startsWith("?")?"":"?")+a.search:"",o=a.hash||"",s=a.auth?a.auth+"@":"",n=a.host||"";return(a.protocol||a[tt]?(a.protocol||"")+"//":"")+s+n+t+e+o}const Ct=/\/([^/]+)$/;function wt(a="",t){const{pathname:e}=H(a),o=e.match(Ct);return o?o[1]:void 0}function K(a){return(U(a.startsWith("/")?a:`/${a}`).pathname||"").split("/").filter(Boolean)}const y=a=>Ut(a??"")?"/":O(v(T(a)))||"/";function $t(a){const t=T(a||"/");return v(t)||"/"}function g(...a){const t=a.filter(n=>typeof n=="string"&&n!=="");if(t.length===0)return"/";const[e,...o]=t,s=I(e,...o)||"/";return W(s)?s:O(s)}function D(a){return a&&U(a).pathname||""}function j(a,t,e){let o=Wt(a,t??{});if(e&&e!=="#"){const s=e.startsWith("#")?e.slice(1):e;o=kt(o,s)}return o}function L(a){if(!a)return"";let t="";for(let e=0;e<a.length;e++)t+=a[e]==="-"?"/":a[e];return t}function G(a){if(!a)return"";const t=a.indexOf("-");return t===-1?a:I(a.slice(0,t),a.slice(t+1))}function M(a){if(!a)return"";const t=a.lastIndexOf("-");return t===-1?a:I(a.slice(0,t),a.slice(t+1))}function jt(a){const t=K(a);return t.length>1?t.slice(0,-1).join("-"):""}function qt(a){return wt(a||"/")??""}function E(a,t){const e=a.name?.toString();if(!e)return null;const o=t.localizedRouteNamePrefix||"localized-",s=e.startsWith(o)?e.slice(o.length):e,n=[...t.locales].sort((r,l)=>l.code.length-r.code.length);for(const r of n){const l=`-${r.code}`;if(!s.endsWith(l))continue;const h=s.length-r.code.length-1;if(h>=0&&s[h]==="-")return s.slice(0,-l.length)}return s}function at(a,t,e="localized-"){return`${e}${a}-${t}`}function q(a,t){if(a==null)return!1;const e=String(a).trim();if(e===""||e==="index")return!0;const o=t?.localizedRouteNamePrefix??"localized-",s=t?.localeCodes??[],n=`${o}index-`;if(!e.startsWith(n))return!1;const r=e.slice(n.length);return s.length===0?r.length>=2:s.includes(r)}function V(a,t){const e=D(a),o=y(e);if(o==="/")return{pathWithoutLocale:"/",localeFromPath:null};if(!_(o))return{pathWithoutLocale:o,localeFromPath:null};const s=o.indexOf("/",1),n=s===-1?o.slice(1):o.slice(1,s);if(n&&t.includes(n)){const r=1+n.length,l=o.slice(r);return{pathWithoutLocale:y(l||"/"),localeFromPath:n}}return{pathWithoutLocale:o,localeFromPath:null}}function st(a,t){const e=D(a);if(e==="/"||e===""||!_(e))return null;const o=e.indexOf("/",1),s=o===-1?e.slice(1):e.slice(1,o);return s&&t.includes(s)?s:null}function Qt(a){return a.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}class ot{constructor(t){this.ctx=t}resolvePathWithParams(t,e={}){let o=t;for(const s in e){const n=e[s];if(n==null||n==="")continue;const r=Array.isArray(n)?n.join("/"):String(n),l=Qt(s),h=new RegExp(`:${l}\\(\\)|:${l}(?![\\w])|\\[\\.\\.\\.${l}\\]`,"g");o=o.replace(h,r)}return o}analyzeRoute(t){const e=this.ctx.locales.map(n=>n.code),{pathWithoutLocale:o}=V(t.path||"/",e);let s=null;return t.name&&(s=E(t,{locales:this.ctx.locales,localizedRouteNamePrefix:this.ctx.localizedRouteNamePrefix||"localized-"})),{pathWithoutLocale:o,baseRouteName:s}}getPathWithoutLocaleAndBaseName(t){return this.analyzeRoute(t)}getLookupKeys(t,e){const o=[];o.push(t);const s=$(t);if(s!==t&&o.push(s),(t==="/"||s==="")&&o.push(""),e){o.push(`/${e}`),o.push(e);const n=L(e);n&&n!==e&&o.push(n);const r=G(e);r&&o.push(r);const l=M(e);l&&o.push(l)}return o}resolveCustomPath(t,e){const o=this.ctx.globalLocaleRoutes;if(!o||Object.keys(o).length===0)return null;const{pathWithoutLocale:s,baseRouteName:n}=this.analyzeRoute(t),r=this.getLookupKeys(s,n);for(const l of r){const h=o[l];if(h&&typeof h=="object"&&!Array.isArray(h)){const u=h[e];if(typeof u=="string")return this.resolvePathWithParams(u,t.params??{})}}return null}getPathForUnlocalizedRoute(t){const e=this.ctx.globalLocaleRoutes;if(!e)return null;const{pathWithoutLocale:o,baseRouteName:s}=this.analyzeRoute(t),n=this.getLookupKeys(o,s);for(const r of n)if(e[r]===!1){if(s&&(r===s||r===`/${s}`)){const l=L(s);return l?g("/",l):`/${s}`}return o}return null}getPathForUnlocalizedRouteByName(t){const e=this.ctx.globalLocaleRoutes;if(!e)return null;const o=[t,`/${t}`,$(t)];for(const s of o)if(e[s]===!1){const n=L(s.startsWith("/")?s.slice(1):s);return n?g("/",n):s.startsWith("/")?s:`/${s}`}return null}getAllowedLocalesForRoute(t){const e=this.ctx.routeLocales;if(!e||Object.keys(e).length===0)return this.ctx.locales.map(r=>r.code);const{pathWithoutLocale:o,baseRouteName:s}=this.analyzeRoute(t);let n=this.getLookupKeys(o,s);s&&this.ctx.routesLocaleLinks?.[s]&&(n=[this.ctx.routesLocaleLinks[s],...n]);for(const r of n){const l=e[r];if(Array.isArray(l)&&l.length>0)return l.filter(h=>this.ctx.locales.some(u=>u.code===h))}return this.ctx.locales.map(r=>r.code)}getParentPathForNested(t,e){if(t.length<=1)return"/";const o=t.length>1?t.slice(0,-1).join("-"):"",s=this.ctx.globalLocaleRoutes;if(o&&s?.[o]&&typeof s[o]=="object"){const n=s[o];if(n[e])return y(n[e])}return g("/",...t.slice(0,-1))}}class Ot{constructor(t){this.ctx=t,this.resolver=new ot(t)}setRouter(t){this.ctx.router=t}getDefaultLocale(){return this.ctx.defaultLocale}getLocales(){return this.ctx.locales}getStrategy(){return this.ctx.strategy}getLocalizedRouteNamePrefix(){return this.ctx.localizedRouteNamePrefix||"localized-"}getGlobalLocaleRoutes(){return this.ctx.globalLocaleRoutes}getRouteLocales(){return this.ctx.routeLocales}getRoutesLocaleLinks(){return this.ctx.routesLocaleLinks}getNoPrefixRedirect(){return this.ctx.noPrefixRedirect}getBaseRouteName(t,e){return E(t,{locales:[{code:e}],localizedRouteNamePrefix:this.getLocalizedRouteNamePrefix()})}getRouteBaseName(t){return E(t,{locales:this.ctx.locales,localizedRouteNamePrefix:this.getLocalizedRouteNamePrefix()})}resolvePathForLocale(t,e){const o={path:t,name:null,fullPath:t,params:{}},s=this.resolver.resolveCustomPath(o,e);return y(s||t)}buildLocalizedName(t,e){return at(t,e,this.getLocalizedRouteNamePrefix())}getLocaleObject(t){return this.ctx.locales.find(e=>e.code===t)}applyBaseUrl(t,e){if(typeof e=="string"){if(W(e))return e}else if(e.path&&W(e.path))return e;const o=this.getLocaleObject(t);if(!o?.baseUrl)return e;const s=v(o.baseUrl);if(typeof e=="string"){const l=y(e.startsWith("/")?e:`/${e}`);return g(s,l)}const n=y(e.path||""),r=g(s,n);return{...e,path:r,fullPath:r}}preserveQueryAndHash(t,e){if(!e||!e.query&&!e.hash)return t;const o=typeof t=="string"?{path:t}:{...t};e.query&&(o.query={...e.query,...o.query}),!o.hash&&e.hash&&(o.hash=e.hash);const s=o.path??"";return o.fullPath=j(s,o.query,o.hash),o}resolvePathWithParams(t,e={}){return this.resolver.resolvePathWithParams(t,e)}getPathWithoutLocaleAndBaseName(t){return this.resolver.getPathWithoutLocaleAndBaseName(t)}getCustomPathSegment(t,e){return this.resolver.resolveCustomPath(t,e)}getAllowedLocalesForRoute(t){return this.resolver.getAllowedLocalesForRoute(t)}getCanonicalPath(t,e){return null}getPathForUnlocalizedRouteByName(t){return this.resolver.getPathForUnlocalizedRouteByName(t)}tryResolveByLocalizedName(t,e,o){const s=`${this.getLocalizedRouteNamePrefix()}${t}-${e}`,n=this.ctx.router.hasRoute(s);if(this.debugLog("tryResolveByLocalizedName",{routeName:t,targetLocale:e,localizedName:s,hasRoute:n}),!n)return null;const r=this.ctx.router.resolve({name:s,params:o?.params,query:o?.query,hash:o?.hash});return this.debugLog("tryResolveByLocalizedName resolved",{localizedName:s,path:r?.path,fullPath:r?.fullPath}),r?.path?{name:s,path:r.path,fullPath:r.fullPath,params:r.params,query:r.query??o?.query,hash:r.hash??o?.hash}:null}tryResolveByLocalizedNameWithParams(t,e,o,s){const n=`${this.getLocalizedRouteNamePrefix()}${t}-${e}`,r=this.ctx.router.hasRoute(n);if(this.debugLog("tryResolveByLocalizedNameWithParams",{routeName:t,targetLocale:e,params:o,localizedName:n,hasRoute:r}),!r)return null;const l=this.ctx.router.resolve({name:n,params:o,query:s?.query,hash:s?.hash});return this.debugLog("tryResolveByLocalizedNameWithParams resolved",{path:l?.path,fullPath:l?.fullPath}),!l?.path||l.path==="/"?null:{name:n,path:l.path,fullPath:l.fullPath,params:l.params,query:l.query??s?.query,hash:l.hash??s?.hash}}getPathForUnlocalizedRoute(t){return this.resolver.getPathForUnlocalizedRoute(t)}buildPathFromBaseNameAndParams(t,e,o){const s=Object.keys(e).filter(m=>e[m]!==void 0&&e[m]!==null&&e[m]!=="");if(s.length===0)return null;let n;const r=s[0];if(s.length===1&&r!==void 0&&t.endsWith("-"+r))n=g("/",t.slice(0,t.length-r.length-1)+"-:"+r);else{const m=L(t),d=m?m.split("/").filter(Boolean):[t],P=Math.min(s.length,d.length),R=d.slice(0,d.length-P).concat(s.slice(0,P).map(S=>`:${S}`));n=g("/",...R)}const l=this.resolvePathWithParams(n,e),h=this.buildLocalizedPath(l,o,!1),u=this.applyBaseUrl(o,h);return typeof u=="string"?u:u.path??h}getPathWithoutLocale(t){return V(t,this.ctx.locales.map(e=>e.code))}getLocaleFromPath(t){return st(t,this.ctx.locales.map(e=>e.code))}getSeoAttributes(t){const e=this.resolveLocaleFromPath(t.path)??this.ctx.defaultLocale,o=this.getCanonicalPath(t,e)??t.path,s=this.buildFullUrl(e,o),n=this.getAllowedLocalesForRoute(t),l=this.ctx.locales.filter(h=>n.includes(h.code)).map(h=>{const u=this.localeRoute(h.code,t,t),d=(u.path??u.fullPath??"")||"/";return{rel:"alternate",hreflang:h.code,href:this.buildFullUrl(h.code,d)}});return{canonical:s,hreflangs:l}}buildFullUrl(t,e){const o=this.applyBaseUrl(t,e);return typeof o=="string"?o:o.path??e}getSwitchLocaleFallbackWhenNoRoute(t,e){return{...t,name:e}}switchLocaleRoute(t,e,o,s){const n=this.getBaseRouteName(o,t);if(!n)return o;let r=this.buildLocalizedRouteName(n,e);if(!this.ctx.router.hasRoute(r))if(this.ctx.router.hasRoute(n))r=n;else return this.getSwitchLocaleFallbackWhenNoRoute(o,r);const l=s.i18nRouteParams?.[e]||{},h={...o.params||{},...l};delete h.locale;const u={name:r,params:h,query:o.query,hash:o.hash};return this.applyBaseUrl(e,u)}localeRoute(t,e,o){const s=this.normalizeRouteInput(e,o),n=this.resolveLocaleRoute(t,s,o);this.debugLog("localeRoute raw",{rawPath:typeof n=="string"?n:n.path,rawFullPath:typeof n=="string"?n:n.fullPath});const r=this.ensureRouteLike(n,s.kind==="route"?s.sourceRoute:void 0);return this.debugLog("localeRoute after ensureRouteLike",{path:r.path,fullPath:r.fullPath}),r}ensureRouteLike(t,e){if(typeof t=="string"){const n=t,r=e?.query||e?.hash?j(n,e?.query,e?.hash):n;return{path:n,fullPath:r,...e?.query&&{query:e.query},...e?.hash&&{hash:e.hash}}}let o=t.fullPath??t.path??"",s=t.path??o.split("?")[0]?.split("#")[0]??o;if(!s&&!o){const n=t.name?.toString()??e?.name?.toString()??"";q(n,{localizedRouteNamePrefix:this.getLocalizedRouteNamePrefix(),localeCodes:this.ctx.locales.map(r=>r.code)})&&(s="/",o="/")}return{...t,path:s,fullPath:o}}normalizeRouteInput(t,e){if(typeof t=="string")return{kind:"path",path:t};const o=t,s=o.name?.toString()??null;let n;try{n=this.ctx.router.resolve(t),this.debugLog("normalizeRouteInput router.resolve ok",{inputName:s,resolvedPath:n.path,resolvedName:n.name})}catch{n={name:s,path:o.path??"/",fullPath:o.fullPath??o.path??"/",params:o.params??{},query:o.query??{},hash:o.hash??""},this.debugLog("normalizeRouteInput router.resolve catch fallback",{inputName:s,resolvedPath:n.path})}return{kind:"route",inputName:s,sourceRoute:o,resolved:n}}debugLog(...t){}resolveLocaleRoute(t,e,o){if(e.kind==="path"){const i=this.resolvePathForLocale(e.path,t),c=this.buildLocalizedPath(i,t,!1),f=this.applyBaseUrl(t,c);return this.debugLog("branch=path",{targetLocale:t,path:e.path,finalPath:c,out:typeof f=="string"?f:f.path}),f}const{inputName:s,sourceRoute:n,resolved:r}=e,l=n.params&&Object.keys(n.params??{}).length>0,h=this.getRouteBaseName(r)??s??r.name?.toString()??null,u=r.name?.toString();if(this.debugLog("input",{targetLocale:t,inputName:s,resolvedPath:r.path,resolvedName:r.name,params:n.params,hasParams:l,baseName:h}),s){const i=this.getPathForUnlocalizedRouteByName(s);if(i!==null)return this.debugLog("branch=unlocalizedByName",{inputName:s,unlocalizedByName:i}),this.preserveQueryAndHash(i,n)}if(s&&l){const i=this.tryResolveByLocalizedNameWithParams(s,t,n.params??{},n);if(i!==null)return this.debugLog("branch=routeWithParams",{inputName:s,path:i.path,fullPath:i.fullPath}),this.preserveQueryAndHash(this.applyBaseUrl(t,i),n)}if(s&&!l){let i=this.tryResolveByLocalizedName(s,t,n);const c=this.getLocalizedRouteNamePrefix();if(i===null&&h!=null&&h!==s&&s.startsWith(c)&&(i=this.tryResolveByLocalizedName(h,t,n)),i!==null)return this.debugLog("branch=routeByLocalizedName",{inputName:s,path:i.path,fullPath:i.fullPath}),this.preserveQueryAndHash(this.applyBaseUrl(t,i),n)}const m=this.getPathForUnlocalizedRoute(r);if(m!==null){const i=this.buildLocalizedPath(m,t,!1);return this.debugLog("branch=unlocalizedPath",{unlocalizedPath:m,path:i}),this.preserveQueryAndHash(this.applyBaseUrl(t,i),n)}const d=this.getCustomPathSegment(r,t);if(d!==null){const i=r.name?.toString()??s??"",c=i?G(i):"",f=i?M(i):"",p=this.ctx.globalLocaleRoutes,x=c.includes("/")&&p?.[c],N=f.includes("/")&&p?.[f],nt=x||N,rt=N?f:c;let F;if(nt){const k=K(rt),z=k.length>1?k.slice(0,-1).join("-"):"",J=z&&p?.[z]&&typeof p[z]=="object"&&!Array.isArray(p[z])?p[z]:null,lt=J?.[t]?y(J[t]):g("/",...k.slice(0,-1)),it=d.startsWith("/")?d.slice(1):d;F=g(lt,it)}else F=y(d);const X=this.buildLocalizedPath(F,t,!0);return this.debugLog("branch=customSegment",{customSegment:d,pathWithoutLocale:F,finalPath:X}),this.preserveQueryAndHash(this.applyBaseUrl(t,X),n)}const P=h??s;if(this.debugLog("before effectiveBaseName check",{baseName:h,inputName:s,effectiveBaseName:P,resolvedName:r.name?.toString()}),!P)return this.debugLog("branch=noBaseName",{return:"src"}),n;if(!l&&r.path&&r.path!=="/"&&r.name){const{pathWithoutLocale:i,baseRouteName:c}=this.getPathWithoutLocaleAndBaseName(r);if(i&&i!=="/"){const f=c&&i===c?g("/",L(c)):i,p=this.buildLocalizedPath(f,t,!1);return this.debugLog("branch=pathFromResolved",{pathWithoutLocale:i,baseRouteName:c,pathToUse:f,finalPath:p}),this.preserveQueryAndHash(this.applyBaseUrl(t,p),n)}}const R=u===s?P:s??P;this.debugLog("fallback build",{resolvedNameStr:u,inputName:s,baseNameForPath:R,targetLocale:t,hasParams:l});const S=this.buildLocalizedRouteName(R,t),b={...n,name:S,params:{...n.params}};if(l){let i=null;try{const c=this.ctx.router.resolve({name:R,params:n.params});if(c?.path){const f=c.path==="/"?"/":(()=>{const{pathWithoutLocale:N}=this.getPathWithoutLocale(c.path);return N&&N!=="/"?N:c.path})(),p=this.buildLocalizedPath(f,t,!1),x=this.applyBaseUrl(t,p);i=typeof x=="string"?x:x.path??p}}catch{i=this.buildPathFromBaseNameAndParams(R,n.params??{},t)}i&&(b.path=i,b.fullPath=i)}else{const i=q(R)?"/":g("/",L(R)),c=this.buildLocalizedPath(i,t,!1),f=this.applyBaseUrl(t,c),p=typeof f=="string"?f:f.path??c;this.debugLog("fallback !hasParams",{pathWithoutLocale:i,finalPath:c,pathStr:p}),b.path=p,b.fullPath=p}const B=this.preserveQueryAndHash(this.applyBaseUrl(t,b),n);return this.debugLog("branch=fallbackNewRoute return",{baseName:h,targetName:S,hasParams:l,newRoutePath:b.path,outPath:typeof B=="string"?B:B.path}),B}}exports.BasePathStrategy=Ot;exports.RouteResolver=ot;exports.buildLocalizedName=at;exports.buildUrl=j;exports.cleanDoubleSlashes=T;exports.getCleanPath=D;exports.getLocaleFromPath=st;exports.getPathSegments=K;exports.getPathWithoutLocale=V;exports.getRouteBaseName=E;exports.isIndexRouteName=q;exports.isSamePath=_t;exports.joinUrl=g;exports.lastPathSegment=qt;exports.nameKeyFirstSlash=G;exports.nameKeyLastSlash=M;exports.normalizePath=y;exports.normalizePathForCompare=$t;exports.parentKeyFromSlashKey=jt;exports.transformNameKeyToPath=L;exports.withLeadingSlash=O;exports.withoutLeadingSlash=$;
|
|
2
|
-
//# sourceMappingURL=base-strategy-B5mBf3XX.cjs.map
|