@i18n-micro/path-strategy 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (37) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +196 -0
  3. package/dist/base-strategy-B5mBf3XX.cjs +2 -0
  4. package/dist/base-strategy-B5mBf3XX.cjs.map +1 -0
  5. package/dist/base-strategy-DVqe8ehd.js +790 -0
  6. package/dist/base-strategy-DVqe8ehd.js.map +1 -0
  7. package/dist/index.cjs +2 -0
  8. package/dist/index.cjs.map +1 -0
  9. package/dist/index.d.ts +394 -0
  10. package/dist/index.mjs +45 -0
  11. package/dist/index.mjs.map +1 -0
  12. package/dist/no-prefix-strategy.cjs +2 -0
  13. package/dist/no-prefix-strategy.cjs.map +1 -0
  14. package/dist/no-prefix-strategy.d.ts +283 -0
  15. package/dist/no-prefix-strategy.mjs +40 -0
  16. package/dist/no-prefix-strategy.mjs.map +1 -0
  17. package/dist/prefix-and-default-strategy.cjs +2 -0
  18. package/dist/prefix-and-default-strategy.cjs.map +1 -0
  19. package/dist/prefix-and-default-strategy.d.ts +284 -0
  20. package/dist/prefix-and-default-strategy.mjs +129 -0
  21. package/dist/prefix-and-default-strategy.mjs.map +1 -0
  22. package/dist/prefix-except-default-strategy.cjs +2 -0
  23. package/dist/prefix-except-default-strategy.cjs.map +1 -0
  24. package/dist/prefix-except-default-strategy.d.ts +298 -0
  25. package/dist/prefix-except-default-strategy.mjs +245 -0
  26. package/dist/prefix-except-default-strategy.mjs.map +1 -0
  27. package/dist/prefix-strategy.cjs +2 -0
  28. package/dist/prefix-strategy.cjs.map +1 -0
  29. package/dist/prefix-strategy.d.ts +277 -0
  30. package/dist/prefix-strategy.mjs +40 -0
  31. package/dist/prefix-strategy.mjs.map +1 -0
  32. package/dist/types.cjs +2 -0
  33. package/dist/types.cjs.map +1 -0
  34. package/dist/types.d.ts +108 -0
  35. package/dist/types.mjs +2 -0
  36. package/dist/types.mjs.map +1 -0
  37. package/package.json +84 -0
@@ -0,0 +1,284 @@
1
+ import { I18nRouteParams } from '@i18n-micro/types';
2
+ import { Locale } from '@i18n-micro/types';
3
+ import { Strategies } from '@i18n-micro/types';
4
+
5
+ declare abstract class BasePathStrategy implements PathStrategy {
6
+ protected ctx: PathStrategyContext;
7
+ protected resolver: RouteResolver;
8
+ constructor(ctx: PathStrategyContext);
9
+ setRouter(router: RouterAdapter): void;
10
+ getDefaultLocale(): string;
11
+ getLocales(): Locale[];
12
+ getStrategy(): PathStrategyContext['strategy'];
13
+ getLocalizedRouteNamePrefix(): string;
14
+ getGlobalLocaleRoutes(): PathStrategyContext['globalLocaleRoutes'];
15
+ getRouteLocales(): PathStrategyContext['routeLocales'];
16
+ getRoutesLocaleLinks(): PathStrategyContext['routesLocaleLinks'];
17
+ getNoPrefixRedirect(): boolean | undefined;
18
+ /** Strips localization prefix/suffix and returns the "base" route name for one locale. */
19
+ 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
+ /** Resolves target path for a locale, checking globalLocaleRoutes first. */
23
+ protected resolvePathForLocale(path: string, targetLocale: string): string;
24
+ protected buildLocalizedName(baseName: string, locale: string): string;
25
+ /** Builds path for target locale (strategy decides: with or without prefix). */
26
+ protected abstract buildLocalizedPath(path: string, locale: string, isCustom: boolean): string;
27
+ /** Builds localized route name for target locale. */
28
+ protected abstract buildLocalizedRouteName(baseName: string, locale: string): string;
29
+ protected getLocaleObject(code: string): Locale | undefined;
30
+ protected applyBaseUrl(localeCode: string, route: RouteLike | string): RouteLike | string;
31
+ /**
32
+ * Merges target route (strategy result) with query and hash from source route.
33
+ * Returns normalized RouteLike object.
34
+ */
35
+ protected preserveQueryAndHash(target: RouteLike | string, source?: RouteLike | null): RouteLike | string;
36
+ protected resolvePathWithParams(path: string, params?: Record<string, unknown>): string;
37
+ protected getPathWithoutLocaleAndBaseName(route: ResolvedRouteLike): {
38
+ pathWithoutLocale: string;
39
+ baseRouteName: string | null;
40
+ };
41
+ /** Look up custom path segment for targetLocale in globalLocaleRoutes. */
42
+ protected getCustomPathSegment(route: ResolvedRouteLike, targetLocale: string): string | null;
43
+ protected getAllowedLocalesForRoute(route: ResolvedRouteLike): string[];
44
+ getCanonicalPath(_route: ResolvedRouteLike, _targetLocale: string): string | null;
45
+ protected getPathForUnlocalizedRouteByName(routeName: string): string | null;
46
+ /**
47
+ * Try to resolve route by localized name. Returns RouteLike with query/hash from sourceRoute to preserve them.
48
+ */
49
+ protected tryResolveByLocalizedName(routeName: string, targetLocale: string, sourceRoute?: RouteLike): RouteLike | null;
50
+ /**
51
+ * Try to resolve route by localized name with params. Returns RouteLike to preserve query/hash.
52
+ */
53
+ protected tryResolveByLocalizedNameWithParams(routeName: string, targetLocale: string, params: Record<string, unknown>, sourceRoute?: RouteLike): RouteLike | null;
54
+ protected getPathForUnlocalizedRoute(route: ResolvedRouteLike): string | null;
55
+ /**
56
+ * Builds localized path from baseName + params when router does not have the route.
57
+ * Tries two conventions:
58
+ * 1) Hyphen form (Nuxt test-[id].vue → /test-:id): when single param key equals last baseName segment (e.g. test-id + id → test-:id).
59
+ * 2) Slash form (kebab→slash): path segments from baseName, last N replaced by :paramKey (e.g. test-id → /test/:id).
60
+ */
61
+ protected buildPathFromBaseNameAndParams(baseName: string, params: Record<string, unknown>, targetLocale: string): string | null;
62
+ protected getPathWithoutLocale(path: string): {
63
+ pathWithoutLocale: string;
64
+ localeFromPath: string | null;
65
+ };
66
+ getLocaleFromPath(path: string): string | null;
67
+ abstract resolveLocaleFromPath(path: string): string | null;
68
+ /**
69
+ * Returns path to redirect to, or null if no redirect needed.
70
+ * Use in middleware: strategy.getRedirect(to.fullPath, detectedLocale)
71
+ */
72
+ abstract getRedirect(currentPath: string, targetLocale: string): string | null;
73
+ /**
74
+ * Builds SEO attributes (canonical + hreflangs) from current route.
75
+ * Respects routeLocales: only allowed locales for this route get an hreflang entry.
76
+ * routesLocaleLinks is used when resolving the route key for routeLocales lookup.
77
+ */
78
+ getSeoAttributes(currentRoute: ResolvedRouteLike): SeoAttributes;
79
+ /**
80
+ * Builds full URL (path + optional baseUrl for locale).
81
+ */
82
+ protected buildFullUrl(localeCode: string, path: string): string;
83
+ /** When router knows neither targetName nor baseName — what to return (strategy may override). */
84
+ protected getSwitchLocaleFallbackWhenNoRoute(route: ResolvedRouteLike, targetName: string): RouteLike | string;
85
+ /**
86
+ * Default: baseName → buildLocalizedRouteName → hasRoute → applyBaseUrl; fallback to baseName.
87
+ */
88
+ switchLocaleRoute(fromLocale: string, toLocale: string, route: ResolvedRouteLike, options: SwitchLocaleOptions): RouteLike | string;
89
+ /**
90
+ * Template Method: BaseStrategy knows "how" (normalize → delegate to strategy).
91
+ * Always returns RouteLike with path and fullPath (never a string).
92
+ */
93
+ localeRoute(targetLocale: string, routeOrPath: RouteLike | string, currentRoute?: ResolvedRouteLike): RouteLike;
94
+ /** Normalizes resolveLocaleRoute result into RouteLike (path and fullPath always set). */
95
+ protected ensureRouteLike(value: RouteLike | string, source?: RouteLike | null): RouteLike;
96
+ /**
97
+ * Normalizes localeRoute input into a single structure (path string or route with resolved).
98
+ */
99
+ protected normalizeRouteInput(routeOrPath: RouteLike | string, _currentRoute?: ResolvedRouteLike): NormalizedRouteInput;
100
+ /** Logging when ctx.debug (for localeRoute debugging). Disabled by default. */
101
+ private debugLog;
102
+ /**
103
+ * Default resolution: uses buildLocalizedPath and buildLocalizedRouteName.
104
+ * Strategies with different logic (e.g. prefix-except-default) override this method.
105
+ */
106
+ protected resolveLocaleRoute(targetLocale: string, normalized: NormalizedRouteInput, _currentRoute?: ResolvedRouteLike): RouteLike | string;
107
+ }
108
+
109
+ /** Custom path rules: route key -> locale -> path segment. false = unlocalized route. */
110
+ declare type GlobalLocaleRoutes = Record<string, Record<string, string> | false>;
111
+
112
+ declare interface HreflangTag {
113
+ rel: 'alternate';
114
+ href: string;
115
+ hreflang: string;
116
+ }
117
+
118
+ /** Normalized input for resolveLocaleRoute (template method). */
119
+ declare type NormalizedRouteInput = {
120
+ kind: 'path';
121
+ path: string;
122
+ } | {
123
+ kind: 'route';
124
+ inputName: string | null;
125
+ sourceRoute: RouteLike;
126
+ resolved: ResolvedRouteLike;
127
+ };
128
+
129
+ declare interface PathStrategy {
130
+ /**
131
+ * Returns a route object to navigate to another locale from the current page.
132
+ */
133
+ switchLocaleRoute(fromLocale: string, toLocale: string, route: ResolvedRouteLike, options: SwitchLocaleOptions): RouteLike | string;
134
+ /**
135
+ * Localizes the given route (object or string) for the target locale.
136
+ * Always returns RouteLike (path and fullPath set). Analogue of $localeRoute / resolveLocalizedRoute.
137
+ */
138
+ localeRoute(targetLocale: string, routeOrPath: RouteLike | string, currentRoute?: ResolvedRouteLike): RouteLike;
139
+ /**
140
+ * Checks if there is a custom path for the given route in globalLocaleRoutes.
141
+ * Used by redirect logic. Returns a path or null.
142
+ */
143
+ getCanonicalPath(route: ResolvedRouteLike, targetLocale: string): string | null;
144
+ /**
145
+ * Determines locale from URL path (strategy-specific).
146
+ * Returns locale code or null if path does not contain a locale (e.g. no_prefix).
147
+ */
148
+ resolveLocaleFromPath(path: string): string | null;
149
+ /**
150
+ * Tries to determine locale from URL path (first segment).
151
+ * Used for initial state and redirect logic. Base implementation in BasePathStrategy.
152
+ */
153
+ getLocaleFromPath(path: string): string | null;
154
+ /**
155
+ * Returns path to redirect to for the given current path and target locale, or null if no redirect needed.
156
+ * Use in middleware: const redirectPath = strategy.getRedirect(to.fullPath, detectedLocale)
157
+ */
158
+ getRedirect(currentPath: string, targetLocale: string): string | null;
159
+ /**
160
+ * Returns SEO attributes (canonical, hreflangs) for useHead.
161
+ */
162
+ getSeoAttributes(currentRoute: ResolvedRouteLike): SeoAttributes;
163
+ /**
164
+ * Sets the router adapter (e.g. when creating singleton and passing router later).
165
+ */
166
+ setRouter(router: RouterAdapter): void;
167
+ getDefaultLocale(): string;
168
+ getLocales(): Locale[];
169
+ getStrategy(): Strategies;
170
+ getLocalizedRouteNamePrefix(): string;
171
+ getGlobalLocaleRoutes(): GlobalLocaleRoutes | undefined;
172
+ getRouteLocales(): Record<string, string[]> | undefined;
173
+ getRoutesLocaleLinks(): Record<string, string> | undefined;
174
+ getNoPrefixRedirect(): boolean | undefined;
175
+ }
176
+
177
+ declare interface PathStrategyContext {
178
+ strategy: Strategies;
179
+ defaultLocale: string;
180
+ locales: Locale[];
181
+ localizedRouteNamePrefix: string;
182
+ globalLocaleRoutes?: GlobalLocaleRoutes;
183
+ routeLocales?: Record<string, string[]>;
184
+ routesLocaleLinks?: Record<string, string>;
185
+ includeDefaultLocaleRoute?: boolean;
186
+ noPrefixRedirect?: boolean;
187
+ debug?: boolean;
188
+ router: RouterAdapter;
189
+ }
190
+
191
+ /**
192
+ * prefix_and_default: default locale has both /path and /en/path.
193
+ * We use prefixed route names for consistency (localized-name-en).
194
+ */
195
+ declare class PrefixAndDefaultPathStrategy extends BasePathStrategy {
196
+ protected buildLocalizedPath(path: string, locale: string, _isCustom: boolean): string;
197
+ protected buildLocalizedRouteName(baseName: string, locale: string): string;
198
+ switchLocaleRoute(fromLocale: string, toLocale: string, route: ResolvedRouteLike, options: SwitchLocaleOptions): RouteLike | string;
199
+ protected resolveLocaleRoute(targetLocale: string, normalized: NormalizedRouteInput, currentRoute?: ResolvedRouteLike): RouteLike | string;
200
+ getCanonicalPath(route: ResolvedRouteLike, targetLocale: string): string | null;
201
+ protected detectLocaleFromName(name: string | null): string | null;
202
+ resolveLocaleFromPath(path: string): string | null;
203
+ getRedirect(currentPath: string, detectedLocale: string): string | null;
204
+ private buildPathWithPrefix;
205
+ }
206
+ export { PrefixAndDefaultPathStrategy }
207
+ export { PrefixAndDefaultPathStrategy as Strategy }
208
+
209
+ /** Resolved route (path and fullPath required). */
210
+ declare interface ResolvedRouteLike extends RouteLike {
211
+ name: string | null;
212
+ path: string;
213
+ fullPath: string;
214
+ }
215
+
216
+ /** Route-like shape (compatible with vue-router). */
217
+ declare interface RouteLike {
218
+ name?: string | null;
219
+ path?: string;
220
+ params?: Record<string, unknown>;
221
+ query?: Record<string, unknown>;
222
+ hash?: string;
223
+ fullPath?: string;
224
+ }
225
+
226
+ declare interface RouterAdapter {
227
+ hasRoute: (name: string) => boolean;
228
+ resolve: (to: RouteLike | string) => ResolvedRouteLike;
229
+ getRoutes?: () => unknown[];
230
+ }
231
+
232
+ declare class RouteResolver {
233
+ private ctx;
234
+ constructor(ctx: PathStrategyContext);
235
+ /**
236
+ * Substitutes params into path template (:key, :key(), [...key]).
237
+ * Uses one combined regex per key to avoid creating multiple RegExp in a loop.
238
+ */
239
+ resolvePathWithParams(path: string, params?: Record<string, unknown>): string;
240
+ /**
241
+ * Analyzes route: path without locale and base name (normalizer + route-name).
242
+ */
243
+ private analyzeRoute;
244
+ /** Public access to route analysis (for strategies). */
245
+ getPathWithoutLocaleAndBaseName(route: ResolvedRouteLike): {
246
+ pathWithoutLocale: string;
247
+ baseRouteName: string | null;
248
+ };
249
+ /**
250
+ * Lookup keys for config (same order for resolveCustomPath, getPathForUnlocalizedRoute, getAllowedLocalesForRoute).
251
+ */
252
+ private getLookupKeys;
253
+ /**
254
+ * Resolves custom path for targetLocale from globalLocaleRoutes.
255
+ */
256
+ resolveCustomPath(route: ResolvedRouteLike, targetLocale: string): string | null;
257
+ /**
258
+ * Unlocalized route (globalLocaleRoutes[key] === false) — returns path without locale.
259
+ */
260
+ getPathForUnlocalizedRoute(route: ResolvedRouteLike): string | null;
261
+ /**
262
+ * Unlocalized by name (when no route object available).
263
+ */
264
+ getPathForUnlocalizedRouteByName(routeName: string): string | null;
265
+ /**
266
+ * Allowed locales for route (routeLocales).
267
+ */
268
+ getAllowedLocalesForRoute(route: ResolvedRouteLike): string[];
269
+ /**
270
+ * Parent path for nested route (parent key -> targetLocale path).
271
+ */
272
+ getParentPathForNested(nameSegments: string[], targetLocale: string): string;
273
+ }
274
+
275
+ declare interface SeoAttributes {
276
+ canonical?: string;
277
+ hreflangs?: HreflangTag[];
278
+ }
279
+
280
+ declare interface SwitchLocaleOptions {
281
+ i18nRouteParams?: I18nRouteParams;
282
+ }
283
+
284
+ export { }
@@ -0,0 +1,129 @@
1
+ import { B as v, j as l, n as F, h as r, k as N, d as S, t as g, w as q, a as w, g as C, i as k } from "./base-strategy-DVqe8ehd.js";
2
+ class K extends v {
3
+ buildLocalizedPath(t, e, s) {
4
+ return l(e, F(t));
5
+ }
6
+ buildLocalizedRouteName(t, e) {
7
+ return this.buildLocalizedName(t, e);
8
+ }
9
+ switchLocaleRoute(t, e, s, i) {
10
+ const o = this.getBaseRouteName(s, t);
11
+ if (!o) return s;
12
+ const h = this.buildLocalizedName(o, e);
13
+ if (this.ctx.router.hasRoute(h)) {
14
+ const m = i.i18nRouteParams?.[e] || {}, u = { ...s.params || {}, ...m };
15
+ return delete u.locale, this.applyBaseUrl(e, {
16
+ name: h,
17
+ params: u,
18
+ query: s.query,
19
+ hash: s.hash
20
+ });
21
+ }
22
+ return { ...s, name: h };
23
+ }
24
+ resolveLocaleRoute(t, e, s) {
25
+ if (e.kind === "path") {
26
+ const a = this.resolvePathForLocale(e.path, t), n = `/${t}`;
27
+ return this.applyBaseUrl(t, l(n, r(a)));
28
+ }
29
+ const { inputName: i, sourceRoute: o, resolved: h } = e;
30
+ if (i) {
31
+ const a = this.getPathForUnlocalizedRouteByName(i);
32
+ if (a !== null) return a;
33
+ }
34
+ const m = o.params && Object.keys(o.params ?? {}).length > 0;
35
+ if (i && m) {
36
+ const a = this.tryResolveByLocalizedNameWithParams(
37
+ i,
38
+ t,
39
+ o.params ?? {},
40
+ o
41
+ );
42
+ if (a !== null) {
43
+ const n = a.path ?? "", { pathWithoutLocale: c } = this.getPathWithoutLocale(n), p = c === "/" || c === "" ? `/${t}` : l(`/${t}`, r(c)), d = N(p, a.query, a.hash), W = {
44
+ ...a,
45
+ path: p,
46
+ fullPath: d
47
+ };
48
+ return this.applyBaseUrl(t, W);
49
+ }
50
+ }
51
+ const u = this.getPathForUnlocalizedRoute(h);
52
+ if (u !== null) return this.applyBaseUrl(t, u);
53
+ const B = this.getCustomPathSegment(h, t);
54
+ if (B !== null) {
55
+ const a = `/${t}`;
56
+ return this.applyBaseUrl(t, l(a, r(B)));
57
+ }
58
+ const P = this.getRouteBaseName(h) ?? i ?? h.name?.toString() ?? null;
59
+ if (i && !m) {
60
+ let a = this.tryResolveByLocalizedName(i, t, o);
61
+ const n = this.getLocalizedRouteNamePrefix();
62
+ if (a === null && P != null && P !== i && i.startsWith(n) && (a = this.tryResolveByLocalizedName(P, t, o)), a !== null) {
63
+ const c = a.path ?? "", { pathWithoutLocale: p } = this.getPathWithoutLocale(c), d = p === "/" || p === "" ? `/${t}` : l(`/${t}`, r(p)), W = N(d, a.query, a.hash), b = {
64
+ ...a,
65
+ path: d,
66
+ fullPath: W
67
+ };
68
+ return this.applyBaseUrl(t, b);
69
+ }
70
+ }
71
+ if (h.path && h.path !== "/" && h.name) {
72
+ const { pathWithoutLocale: a } = this.getPathWithoutLocaleAndBaseName(h);
73
+ if (a && a !== "/")
74
+ return this.applyBaseUrl(t, l(`/${t}`, r(a)));
75
+ }
76
+ const R = s ? this.detectLocaleFromName(s.name) : this.detectLocaleFromName(h.name), f = R ? this.getBaseRouteName(h, R) : P;
77
+ if (!f) {
78
+ const { pathWithoutLocale: a } = this.getPathWithoutLocale(h.path ?? "/"), n = a === "/" || a === "" ? `/${t}` : l(`/${t}`, r(a)), c = N(n, o.query, o.hash);
79
+ return this.applyBaseUrl(t, {
80
+ ...o,
81
+ path: n,
82
+ fullPath: c
83
+ });
84
+ }
85
+ const z = this.buildLocalizedName(f, t), U = S(f) ? "/" : l("/", g(f)), L = l(`/${t}`, r(U)), y = this.applyBaseUrl(t, L), x = typeof y == "string" ? y : y.path ?? L, $ = {
86
+ name: z,
87
+ path: x,
88
+ fullPath: x,
89
+ params: { ...h.params, ...o.params },
90
+ query: { ...h.query, ...o.query },
91
+ hash: o.hash ?? h.hash
92
+ };
93
+ return this.applyBaseUrl(t, $);
94
+ }
95
+ getCanonicalPath(t, e) {
96
+ const s = this.getCustomPathSegment(t, e);
97
+ return s ? l(`/${e}`, r(s)) : null;
98
+ }
99
+ detectLocaleFromName(t) {
100
+ if (!t) return null;
101
+ for (const e of this.ctx.locales)
102
+ if (t.endsWith(`-${e.code}`))
103
+ return e.code;
104
+ return null;
105
+ }
106
+ resolveLocaleFromPath(t) {
107
+ const { localeFromPath: e } = this.getPathWithoutLocale(t);
108
+ return e;
109
+ }
110
+ getRedirect(t, e) {
111
+ const { pathWithoutLocale: s, localeFromPath: i } = this.getPathWithoutLocale(t), o = this.ctx.globalLocaleRoutes;
112
+ if (o && i !== null) {
113
+ const u = s === "/" ? "/" : q(s);
114
+ if (o[s] === !1 || o[u] === !1)
115
+ return w(s === "/" ? "/" : s);
116
+ }
117
+ const h = this.buildPathWithPrefix(s, e), m = C(t);
118
+ return i === e && k(m, h) ? null : h;
119
+ }
120
+ buildPathWithPrefix(t, e) {
121
+ const s = this.resolvePathForLocale(t, e);
122
+ return s === "/" || s === "" ? `/${e}` : l(`/${e}`, s);
123
+ }
124
+ }
125
+ export {
126
+ K as PrefixAndDefaultPathStrategy,
127
+ K as Strategy
128
+ };
129
+ //# sourceMappingURL=prefix-and-default-strategy.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"prefix-and-default-strategy.mjs","sources":["../src/strategies/prefix-and-default.ts"],"sourcesContent":["import type { NormalizedRouteInput, ResolvedRouteLike, RouteLike, SwitchLocaleOptions } from '../core/types'\nimport { BasePathStrategy } from './base-strategy'\nimport { isSamePath, withLeadingSlash, withoutLeadingSlash } from 'ufo'\nimport { buildUrl, getCleanPath, joinUrl, normalizePath, normalizePathForCompare, transformNameKeyToPath } from '../utils/path'\nimport { isIndexRouteName } from '../utils/route-name'\n\n/**\n * prefix_and_default: default locale has both /path and /en/path.\n * We use prefixed route names for consistency (localized-name-en).\n */\nexport class PrefixAndDefaultPathStrategy extends BasePathStrategy {\n protected buildLocalizedPath(path: string, locale: string, _isCustom: boolean): string {\n return joinUrl(locale, normalizePath(path))\n }\n\n protected buildLocalizedRouteName(baseName: string, locale: string): string {\n return this.buildLocalizedName(baseName, locale)\n }\n\n override switchLocaleRoute(\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.buildLocalizedName(baseName, toLocale)\n\n if (this.ctx.router.hasRoute(targetName)) {\n const i18nParams = options.i18nRouteParams?.[toLocale] || {}\n const newParams = { ...(route.params || {}), ...i18nParams }\n delete (newParams as Record<string, unknown>).locale\n\n return this.applyBaseUrl(toLocale, {\n name: targetName,\n params: newParams,\n query: route.query,\n hash: route.hash,\n }) as RouteLike\n }\n\n 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 resolvedPath = this.resolvePathForLocale(normalized.path, targetLocale)\n const prefix = `/${targetLocale}`\n return this.applyBaseUrl(targetLocale, joinUrl(prefix, withLeadingSlash(resolvedPath)))\n }\n\n const { inputName, sourceRoute, resolved } = normalized\n if (inputName) {\n const unlocalizedByName = this.getPathForUnlocalizedRouteByName(inputName)\n if (unlocalizedByName !== null) return unlocalizedByName\n }\n const hasParams = sourceRoute.params && Object.keys(sourceRoute.params ?? {}).length > 0\n if (inputName && hasParams) {\n const routeWithParams = this.tryResolveByLocalizedNameWithParams(\n inputName,\n targetLocale,\n sourceRoute.params ?? {},\n sourceRoute,\n )\n if (routeWithParams !== null) {\n const resolvedPath = routeWithParams.path ?? ''\n const { pathWithoutLocale } = this.getPathWithoutLocale(resolvedPath)\n const pathWithLocale = pathWithoutLocale === '/' || pathWithoutLocale === ''\n ? `/${targetLocale}`\n : joinUrl(`/${targetLocale}`, withLeadingSlash(pathWithoutLocale))\n const fullPathWithLocale = buildUrl(pathWithLocale, routeWithParams.query, routeWithParams.hash)\n const routeWithPath: RouteLike = {\n ...routeWithParams,\n path: pathWithLocale,\n fullPath: fullPathWithLocale,\n }\n return this.applyBaseUrl(targetLocale, routeWithPath)\n }\n }\n\n const unlocalizedPath = this.getPathForUnlocalizedRoute(resolved)\n if (unlocalizedPath !== null) return this.applyBaseUrl(targetLocale, unlocalizedPath)\n\n const customSegment = this.getCustomPathSegment(resolved, targetLocale)\n if (customSegment !== null) {\n const prefix = `/${targetLocale}`\n return this.applyBaseUrl(targetLocale, joinUrl(prefix, withLeadingSlash(customSegment)))\n }\n const baseName = this.getRouteBaseName(resolved) ?? inputName ?? resolved.name?.toString() ?? null\n if (inputName && !hasParams) {\n let routeByLocalizedName = this.tryResolveByLocalizedName(inputName, targetLocale, sourceRoute)\n const prefix = this.getLocalizedRouteNamePrefix()\n if (routeByLocalizedName === null && baseName != null && baseName !== inputName && inputName.startsWith(prefix)) {\n routeByLocalizedName = this.tryResolveByLocalizedName(baseName, targetLocale, sourceRoute)\n }\n if (routeByLocalizedName !== null) {\n // Router may return path without locale prefix (e.g. Nuxt file-based /contact). For prefix_and_default\n // we always need path with locale (e.g. /en/contact).\n const resolvedPath = routeByLocalizedName.path ?? ''\n const { pathWithoutLocale } = this.getPathWithoutLocale(resolvedPath)\n const pathWithLocale = pathWithoutLocale === '/' || pathWithoutLocale === ''\n ? `/${targetLocale}`\n : joinUrl(`/${targetLocale}`, withLeadingSlash(pathWithoutLocale))\n const fullPathWithLocale = buildUrl(pathWithLocale, routeByLocalizedName.query, routeByLocalizedName.hash)\n const routeWithPath: RouteLike = {\n ...routeByLocalizedName,\n path: pathWithLocale,\n fullPath: fullPathWithLocale,\n }\n return this.applyBaseUrl(targetLocale, routeWithPath)\n }\n }\n if (resolved.path && resolved.path !== '/' && resolved.name) {\n const { pathWithoutLocale } = this.getPathWithoutLocaleAndBaseName(resolved)\n if (pathWithoutLocale && pathWithoutLocale !== '/') {\n return this.applyBaseUrl(targetLocale, joinUrl(`/${targetLocale}`, withLeadingSlash(pathWithoutLocale)))\n }\n }\n\n const fromLocale = currentRoute\n ? this.detectLocaleFromName(currentRoute.name)\n : this.detectLocaleFromName(resolved.name)\n\n const fallbackBaseName = fromLocale\n ? this.getBaseRouteName(resolved, fromLocale)\n : baseName\n\n if (!fallbackBaseName) {\n // Never return unprefixed path for prefix_and_default. Build path from resolved.\n const { pathWithoutLocale } = this.getPathWithoutLocale(resolved.path ?? '/')\n const pathWithLocale = pathWithoutLocale === '/' || pathWithoutLocale === ''\n ? `/${targetLocale}`\n : joinUrl(`/${targetLocale}`, withLeadingSlash(pathWithoutLocale))\n const fullPathWithLocale = buildUrl(pathWithLocale, sourceRoute.query, sourceRoute.hash)\n return this.applyBaseUrl(targetLocale, {\n ...sourceRoute,\n path: pathWithLocale,\n fullPath: fullPathWithLocale,\n })\n }\n\n const targetName = this.buildLocalizedName(fallbackBaseName, targetLocale)\n\n const pathWithoutLocale = isIndexRouteName(fallbackBaseName)\n ? '/'\n : joinUrl('/', transformNameKeyToPath(fallbackBaseName))\n const pathForLocale = joinUrl(`/${targetLocale}`, withLeadingSlash(pathWithoutLocale))\n const withBase = this.applyBaseUrl(targetLocale, pathForLocale)\n const pathStr = typeof withBase === 'string' ? withBase : (withBase as RouteLike).path ?? pathForLocale\n\n const newRoute: RouteLike = {\n name: targetName,\n path: pathStr,\n fullPath: pathStr,\n params: { ...resolved.params, ...sourceRoute.params },\n query: { ...resolved.query, ...sourceRoute.query },\n hash: sourceRoute.hash ?? resolved.hash,\n }\n return this.applyBaseUrl(targetLocale, newRoute)\n }\n\n override getCanonicalPath(route: ResolvedRouteLike, targetLocale: string): string | null {\n const segment = this.getCustomPathSegment(route, targetLocale)\n if (!segment) return null\n return joinUrl(`/${targetLocale}`, withLeadingSlash(segment))\n }\n\n protected detectLocaleFromName(name: string | null): string | null {\n if (!name) return null\n for (const locale of this.ctx.locales) {\n if (name.endsWith(`-${locale.code}`)) {\n return locale.code\n }\n }\n return null\n }\n\n resolveLocaleFromPath(path: string): string | null {\n const { localeFromPath } = this.getPathWithoutLocale(path)\n return localeFromPath\n }\n\n getRedirect(currentPath: string, detectedLocale: string): string | null {\n const { pathWithoutLocale, localeFromPath } = this.getPathWithoutLocale(currentPath)\n // Unlocalized routes (globalLocaleRoutes[key] === false): redirect /locale/path to /path\n const gr = this.ctx.globalLocaleRoutes\n if (gr && localeFromPath !== null) {\n const pathKey = pathWithoutLocale === '/' ? '/' : withoutLeadingSlash(pathWithoutLocale)\n if (gr[pathWithoutLocale] === false || gr[pathKey] === false) {\n return normalizePathForCompare(pathWithoutLocale === '/' ? '/' : pathWithoutLocale)\n }\n }\n const expectedPath = this.buildPathWithPrefix(pathWithoutLocale, detectedLocale)\n const currentPathOnly = getCleanPath(currentPath)\n if (localeFromPath === detectedLocale && isSamePath(currentPathOnly, expectedPath)) {\n return null\n }\n return expectedPath\n }\n\n private buildPathWithPrefix(pathWithoutLocale: string, locale: string): string {\n const resolved = this.resolvePathForLocale(pathWithoutLocale, locale)\n if (resolved === '/' || resolved === '') {\n return `/${locale}`\n }\n return joinUrl(`/${locale}`, resolved)\n }\n}\n\n/** Alias for Nuxt alias consumption. */\nexport { PrefixAndDefaultPathStrategy as Strategy }\n"],"names":["PrefixAndDefaultPathStrategy","BasePathStrategy","path","locale","_isCustom","joinUrl","normalizePath","baseName","fromLocale","toLocale","route","options","targetName","i18nParams","newParams","targetLocale","normalized","currentRoute","resolvedPath","prefix","withLeadingSlash","inputName","sourceRoute","resolved","unlocalizedByName","hasParams","routeWithParams","pathWithoutLocale","pathWithLocale","fullPathWithLocale","buildUrl","routeWithPath","unlocalizedPath","customSegment","routeByLocalizedName","fallbackBaseName","isIndexRouteName","transformNameKeyToPath","pathForLocale","withBase","pathStr","newRoute","segment","name","localeFromPath","currentPath","detectedLocale","gr","pathKey","withoutLeadingSlash","normalizePathForCompare","expectedPath","currentPathOnly","getCleanPath","isSamePath"],"mappings":";AAU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E7EE,IAAK,KAAK,IAAI;AACpB,QAAIA,KAAMH,MAAmB,MAAM;AACjC,YAAMI,IAAUrB,MAAsB,MAAM,MAAMsB,EAAoBtB,CAAiB;AACvF,UAAIoB,EAAGpB,CAAiB,MAAM,MAASoB,EAAGC,CAAO,MAAM;AACrD,eAAOE,EAAwBvB,MAAsB,MAAM,MAAMA,CAAiB;AAAA,IAEtF;AACA,UAAMwB,IAAe,KAAK,oBAAoBxB,GAAmBmB,CAAc,GACzEM,IAAkBC,EAAaR,CAAW;AAChD,WAAID,MAAmBE,KAAkBQ,EAAWF,GAAiBD,CAAY,IACxE,OAEFA;AAAA,EACT;AAAA,EAEQ,oBAAoBxB,GAA2BxB,GAAwB;AAC7E,UAAMoB,IAAW,KAAK,qBAAqBI,GAAmBxB,CAAM;AACpE,WAAIoB,MAAa,OAAOA,MAAa,KAC5B,IAAIpB,CAAM,KAEZE,EAAQ,IAAIF,CAAM,IAAIoB,CAAQ;AAAA,EACvC;AACF;"}
@@ -0,0 +1,2 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s=require("./base-strategy-B5mBf3XX.cjs");class R extends s.BasePathStrategy{shouldHavePrefix(t){return this.ctx.includeDefaultLocaleRoute?!0:t!==this.ctx.defaultLocale}buildLocalizedPath(t,a,e){return this.shouldHavePrefix(a)?s.joinUrl(a,s.normalizePath(t)):s.normalizePath(t)}buildLocalizedRouteName(t,a){return this.shouldHavePrefix(a)?this.buildLocalizedName(t,a):t}switchLocaleRoute(t,a,e,i){const n=this.getBaseRouteName(e,t);if(!n)return e;const h=this.shouldHavePrefix(a)?this.buildLocalizedName(n,a):n;if(this.ctx.router.hasRoute(h)){const c=i.i18nRouteParams?.[a]||{},p={...e.params||{},...c};delete p.locale;const S={name:h,params:p,query:e.query,hash:e.hash};return this.applyBaseUrl(a,S)}return{...e,name:h}}resolveLocaleRoute(t,a,e){if(a.kind==="path"){const u=this.resolvePathForLocale(a.path,t);if(!this.shouldHavePrefix(t))return this.applyBaseUrl(t,u);const P=s.joinUrl(t,u);return this.applyBaseUrl(t,P)}const{inputName:i,sourceRoute:n,resolved:h}=a;if(i){const u=this.getPathForUnlocalizedRouteByName(i);if(u!==null)return this.preserveQueryAndHash(u,n);const o="/"+s.nameKeyLastSlash(i),m={name:i,path:o,fullPath:o,params:n.params??{}},r=this.getCustomPathSegment(m,t);if(r!==null){const l=this.getNestedRouteInfo(i);let f;if(l){const d=this.getParentPathForTarget(l.parentKey,l.keyWithSlash,t,e),v=r.startsWith("/")?r.slice(1):r;f=d?s.joinUrl(d,v):s.normalizePath(r)}else f=s.normalizePath(r);if(!this.shouldHavePrefix(t))return this.preserveQueryAndHash(this.applyBaseUrl(t,f),n);const y=s.joinUrl(t,f);return this.preserveQueryAndHash(this.applyBaseUrl(t,y),n)}}const c=n.params&&Object.keys(n.params??{}).length>0;if(i&&c){const u=this.tryResolveByLocalizedNameWithParams(i,t,n.params??{},n);if(u!==null){const P=this.applyBaseUrl(t,u);return this.preserveQueryAndHash(P,n)}}if(h.name!=null){const u=this.getPathForUnlocalizedRoute(h);if(u!==null)return this.preserveQueryAndHash(this.applyBaseUrl(t,u),n);const P=this.getCustomPathSegment(h,t);if(P!==null){const o=h.name?.toString()??i??"",m=o?this.getNestedRouteInfo(o):null;let r;if(m){const f=this.getParentPathForTarget(m.parentKey,m.keyWithSlash,t,e),y=P.startsWith("/")?P.slice(1):P;r=s.joinUrl(f,y)}else r=s.normalizePath(P);if(!this.shouldHavePrefix(t))return this.preserveQueryAndHash(this.applyBaseUrl(t,r),n);const l=s.joinUrl(t,r);return this.preserveQueryAndHash(this.applyBaseUrl(t,l),n)}if(h.path&&h.path!=="/"&&h.name){const{pathWithoutLocale:o,baseRouteName:m}=this.getPathWithoutLocaleAndBaseName(h),r=this.getCustomPathSegment(h,t),l=m?this.getNestedRouteInfo(m):null,f=!!l;let y;if(r!==null&&f&&l){const d=this.getParentPathForTarget(l.parentKey,l.keyWithSlash,t,e),v=r.startsWith("/")?r.slice(1):r;y=s.joinUrl(d,v)}else if(f&&r===null&&o&&o!=="/"&&l){const d=this.getParentPathForTarget(l.parentKey,l.keyWithSlash,t,e),v=s.lastPathSegment(o);y=d?s.joinUrl(d,v):o!=="/"?o:null}else y=r!==null&&!f?s.normalizePath(r):o&&o!=="/"?o:null;if(y){const d=this.detectLocaleFromName(h.name),v=d?this.getBaseRouteName(h,d):h.name?this.getRouteBaseName(h):null,F=v?this.shouldHavePrefix(t)?this.buildLocalizedName(v,t):v.toString():void 0,B=this.shouldHavePrefix(t)?s.joinUrl(t,y):y,b={...F?{name:F}:{},path:B,fullPath:B,params:{...h.params,...n.params},query:{...h.query,...n.query},hash:n.hash??h.hash};return this.preserveQueryAndHash(this.applyBaseUrl(t,b),n)}}}if(i){const P="/"+s.nameKeyLastSlash(i),o={name:i,path:P,fullPath:P,params:n.params??{}},m=this.getCustomPathSegment(o,t);if(m!==null){const r=this.getNestedRouteInfo(i);let l;if(r){const y=this.getParentPathForTarget(r.parentKey,r.keyWithSlash,t,e),d=m.startsWith("/")?m.slice(1):m;l=s.joinUrl(y||"/",d)}else l=s.normalizePath(m);if(!this.shouldHavePrefix(t))return this.preserveQueryAndHash(this.applyBaseUrl(t,l),n);const f=s.joinUrl(t,l);return this.preserveQueryAndHash(this.applyBaseUrl(t,f),n)}}if(i&&!c){const u=this.tryResolveByLocalizedName(i,t,n);if(u!==null)return this.preserveQueryAndHash(this.applyBaseUrl(t,u),n)}const p=e?this.detectLocaleFromName(e.name):this.detectLocaleFromName(h.name),S=p?this.getBaseRouteName(h,p):h.name??null;if(!S)return n;const x=this.shouldHavePrefix(t)?this.buildLocalizedName(S,t):S.toString(),N=s.isIndexRouteName(S)?"/":s.joinUrl("/",s.transformNameKeyToPath(S)),U=this.shouldHavePrefix(t)?s.joinUrl(t,N):N,g=this.applyBaseUrl(t,U),W=typeof g=="string"?g:g.path??U,H={name:x,path:W,fullPath:W,params:{...h.params,...n.params},query:{...h.query,...n.query},hash:n.hash??h.hash};return this.preserveQueryAndHash(this.applyBaseUrl(t,H),n)}getCanonicalPath(t,a){const e=this.getCustomPathSegment(t,a);if(!e)return null;const i=e.startsWith("/")?e:`/${e}`;return this.shouldHavePrefix(a)?s.cleanDoubleSlashes(`/${a}${i}`):s.cleanDoubleSlashes(i)}resolveLocaleFromPath(t){const{localeFromPath:a}=this.getPathWithoutLocale(t);return a||this.ctx.defaultLocale}getRedirect(t,a){const{pathWithoutLocale:e,localeFromPath:i}=this.getPathWithoutLocale(t),n=this.shouldHavePrefix(a),h=this.ctx.globalLocaleRoutes;if(h&&i!==null){const x=e==="/"?"/":s.withoutLeadingSlash(e);if(h[e]===!1||h[x]===!1)return s.normalizePathForCompare(e)}if(i!==null){if(i===this.ctx.defaultLocale)return s.normalizePathForCompare(e);if(i===a){const x=this.buildPathWithPrefix(e,a),N=s.getCleanPath(t);return s.isSamePath(N,x)?null:x}return this.buildPathWithPrefix(e,a)}if(n)return this.buildPathWithPrefix(e,a);const c=this.resolvePathForLocale(e,a),p=c.startsWith("/")?c:`/${c}`,S=s.getCleanPath(t);return s.isSamePath(S,p)?null:p}isLocaleRules(t){const a=this.ctx.globalLocaleRoutes;if(!a||!t)return!1;const e=a[t];return typeof e=="object"&&e!==null&&!Array.isArray(e)}getNestedRouteInfo(t){if(!this.ctx.globalLocaleRoutes)return null;const e=s.nameKeyLastSlash(t),i=s.nameKeyFirstSlash(t);if(e.includes("/")&&this.isLocaleRules(e))return{parentKey:s.parentKeyFromSlashKey(e),keyWithSlash:e};if(i.includes("/")&&this.isLocaleRules(i))return{parentKey:s.parentKeyFromSlashKey(i),keyWithSlash:i};const n=s.parentKeyFromSlashKey(e);if(e.includes("/")&&n&&this.isLocaleRules(n))return{parentKey:n,keyWithSlash:e};const h=s.parentKeyFromSlashKey(i);return i.includes("/")&&h&&this.isLocaleRules(h)?{parentKey:h,keyWithSlash:i}:null}getParentPathForTarget(t,a,e,i){const n=this.ctx.globalLocaleRoutes,h=t&&n?.[t]&&typeof n[t]=="object"&&!Array.isArray(n[t])?n[t]:null;let c=h?.[e]?s.normalizePath(h[e]):"";if(!c&&i?.path){const p=s.getCleanPath(i.path),{pathWithoutLocale:S}=this.getPathWithoutLocale(p);c=s.normalizePath(S)}if(!c){const p=s.getPathSegments(a).slice(0,-1);c=p.length?s.joinUrl("/",...p):""}return c}buildPathWithPrefix(t,a){const e=this.resolvePathForLocale(t,a);return e==="/"||e===""?`/${a}`:s.joinUrl(`/${a}`,e)}detectLocaleFromName(t){if(!t)return null;for(const a of this.ctx.locales)if(t.endsWith(`-${a.code}`))return a.code;return null}}exports.PrefixExceptDefaultPathStrategy=R;exports.Strategy=R;
2
+ //# sourceMappingURL=prefix-except-default-strategy.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"prefix-except-default-strategy.cjs","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":"gIAMO,MAAMA,UAAwCC,EAAAA,gBAAiB,CAK1D,iBAAiBC,EAAyB,CAClD,OAAI,KAAK,IAAI,0BAAkC,GACxCA,IAAW,KAAK,IAAI,aAC7B,CAEU,mBAAmBC,EAAcD,EAAgBE,EAA4B,CACrF,OAAK,KAAK,iBAAiBF,CAAM,EAC1BG,UAAQH,EAAQI,EAAAA,cAAcH,CAAI,CAAC,EADCG,EAAAA,cAAcH,CAAI,CAE/D,CAEU,wBAAwBI,EAAkBL,EAAwB,CAC1E,OAAK,KAAK,iBAAiBA,CAAM,EAC1B,KAAK,mBAAmBK,EAAUL,CAAM,EADJK,CAE7C,CAES,kBACPC,EACAC,EACAC,EACAC,EACoB,CACpB,MAAMJ,EAAW,KAAK,iBAAiBG,EAAOF,CAAU,EACxD,GAAI,CAACD,EAAU,OAAOG,EAEtB,MAAME,EAAa,KAAK,iBAAiBH,CAAQ,EAC7C,KAAK,mBAAmBF,EAAUE,CAAQ,EAC1CF,EAEJ,GAAI,KAAK,IAAI,OAAO,SAASK,CAAU,EAAG,CACxC,MAAMC,EAAaF,EAAQ,kBAAkBF,CAAQ,GAAK,CAAA,EACpDK,EAAqC,CAAE,GAAIJ,EAAM,QAAU,CAAA,EAAK,GAAGG,CAAA,EACzE,OAAOC,EAAU,OAEjB,MAAMC,EAAsB,CAC1B,KAAMH,EACN,OAAQE,EACR,MAAOJ,EAAM,MACb,KAAMA,EAAM,IAAA,EAGd,OAAO,KAAK,aAAaD,EAAUM,CAAQ,CAC7C,CAEA,MAAO,CAAE,GAAGL,EAAO,KAAME,CAAA,CAC3B,CAEmB,mBACjBI,EACAC,EACAC,EACoB,CACpB,GAAID,EAAW,OAAS,OAAQ,CAC9B,MAAMd,EAAO,KAAK,qBAAqBc,EAAW,KAAMD,CAAY,EACp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