@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.
- package/LICENSE +21 -0
- package/README.md +196 -0
- package/dist/base-strategy-B5mBf3XX.cjs +2 -0
- package/dist/base-strategy-B5mBf3XX.cjs.map +1 -0
- package/dist/base-strategy-DVqe8ehd.js +790 -0
- package/dist/base-strategy-DVqe8ehd.js.map +1 -0
- package/dist/index.cjs +2 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.ts +394 -0
- package/dist/index.mjs +45 -0
- package/dist/index.mjs.map +1 -0
- package/dist/no-prefix-strategy.cjs +2 -0
- package/dist/no-prefix-strategy.cjs.map +1 -0
- package/dist/no-prefix-strategy.d.ts +283 -0
- package/dist/no-prefix-strategy.mjs +40 -0
- package/dist/no-prefix-strategy.mjs.map +1 -0
- package/dist/prefix-and-default-strategy.cjs +2 -0
- package/dist/prefix-and-default-strategy.cjs.map +1 -0
- package/dist/prefix-and-default-strategy.d.ts +284 -0
- package/dist/prefix-and-default-strategy.mjs +129 -0
- package/dist/prefix-and-default-strategy.mjs.map +1 -0
- package/dist/prefix-except-default-strategy.cjs +2 -0
- package/dist/prefix-except-default-strategy.cjs.map +1 -0
- package/dist/prefix-except-default-strategy.d.ts +298 -0
- package/dist/prefix-except-default-strategy.mjs +245 -0
- package/dist/prefix-except-default-strategy.mjs.map +1 -0
- package/dist/prefix-strategy.cjs +2 -0
- package/dist/prefix-strategy.cjs.map +1 -0
- package/dist/prefix-strategy.d.ts +277 -0
- package/dist/prefix-strategy.mjs +40 -0
- package/dist/prefix-strategy.mjs.map +1 -0
- package/dist/types.cjs +2 -0
- package/dist/types.cjs.map +1 -0
- package/dist/types.d.ts +108 -0
- package/dist/types.mjs +2 -0
- package/dist/types.mjs.map +1 -0
- package/package.json +84 -0
|
@@ -0,0 +1,790 @@
|
|
|
1
|
+
const rt = /#/g, lt = /&/g, it = /\//g, ct = /=/g, $ = /\+/g, G = /%5e/gi, ht = /%60/gi, ut = /%7b/gi, ft = /%7c/gi, pt = /%7d/gi, dt = /%20/gi;
|
|
2
|
+
function D(s) {
|
|
3
|
+
return encodeURI("" + s).replace(ft, "|");
|
|
4
|
+
}
|
|
5
|
+
function mt(s) {
|
|
6
|
+
return D(s).replace(ut, "{").replace(pt, "}").replace(G, "^");
|
|
7
|
+
}
|
|
8
|
+
function w(s) {
|
|
9
|
+
return D(typeof s == "string" ? s : JSON.stringify(s)).replace($, "%2B").replace(dt, "+").replace(rt, "%23").replace(lt, "%26").replace(ht, "`").replace(G, "^").replace(it, "%2F");
|
|
10
|
+
}
|
|
11
|
+
function _(s) {
|
|
12
|
+
return w(s).replace(ct, "%3D");
|
|
13
|
+
}
|
|
14
|
+
function F(s = "") {
|
|
15
|
+
try {
|
|
16
|
+
return decodeURIComponent("" + s);
|
|
17
|
+
} catch {
|
|
18
|
+
return "" + s;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
function gt(s) {
|
|
22
|
+
return F(s.replace($, " "));
|
|
23
|
+
}
|
|
24
|
+
function Pt(s) {
|
|
25
|
+
return F(s.replace($, " "));
|
|
26
|
+
}
|
|
27
|
+
function yt(s = "") {
|
|
28
|
+
const t = /* @__PURE__ */ Object.create(null);
|
|
29
|
+
s[0] === "?" && (s = s.slice(1));
|
|
30
|
+
for (const e of s.split("&")) {
|
|
31
|
+
const o = e.match(/([^=]+)=?(.*)/) || [];
|
|
32
|
+
if (o.length < 2)
|
|
33
|
+
continue;
|
|
34
|
+
const a = gt(o[1]);
|
|
35
|
+
if (a === "__proto__" || a === "constructor")
|
|
36
|
+
continue;
|
|
37
|
+
const n = Pt(o[2] || "");
|
|
38
|
+
t[a] === void 0 ? t[a] = n : Array.isArray(t[a]) ? t[a].push(n) : t[a] = [t[a], n];
|
|
39
|
+
}
|
|
40
|
+
return t;
|
|
41
|
+
}
|
|
42
|
+
function Rt(s, t) {
|
|
43
|
+
return (typeof t == "number" || typeof t == "boolean") && (t = String(t)), t ? Array.isArray(t) ? t.map(
|
|
44
|
+
(e) => `${_(s)}=${w(e)}`
|
|
45
|
+
).join("&") : `${_(s)}=${w(t)}` : _(s);
|
|
46
|
+
}
|
|
47
|
+
function Lt(s) {
|
|
48
|
+
return Object.keys(s).filter((t) => s[t] !== void 0).map((t) => Rt(t, s[t])).filter(Boolean).join("&");
|
|
49
|
+
}
|
|
50
|
+
const bt = /^[\s\w\0+.-]{2,}:([/\\]{1,2})/, Nt = /^[\s\w\0+.-]{2,}:([/\\]{2})?/, xt = /^([/\\]\s*){2,}[^/\\]/, zt = /^\.?\//;
|
|
51
|
+
function W(s, t = {}) {
|
|
52
|
+
return typeof t == "boolean" && (t = { acceptRelative: t }), t.strict ? bt.test(s) : Nt.test(s) || (t.acceptRelative ? xt.test(s) : !1);
|
|
53
|
+
}
|
|
54
|
+
function vt(s = "", t) {
|
|
55
|
+
return s.endsWith("/");
|
|
56
|
+
}
|
|
57
|
+
function v(s = "", t) {
|
|
58
|
+
return (vt(s) ? s.slice(0, -1) : s) || "/";
|
|
59
|
+
}
|
|
60
|
+
function Bt(s = "", t) {
|
|
61
|
+
return s.endsWith("/") ? s : s + "/";
|
|
62
|
+
}
|
|
63
|
+
function U(s = "") {
|
|
64
|
+
return s.startsWith("/");
|
|
65
|
+
}
|
|
66
|
+
function T(s = "") {
|
|
67
|
+
return (U(s) ? s.slice(1) : s) || "/";
|
|
68
|
+
}
|
|
69
|
+
function K(s = "") {
|
|
70
|
+
return U(s) ? s : "/" + s;
|
|
71
|
+
}
|
|
72
|
+
function M(s = "") {
|
|
73
|
+
return s.split("://").map((t) => t.replace(/\/{2,}/g, "/")).join("://");
|
|
74
|
+
}
|
|
75
|
+
function St(s, t) {
|
|
76
|
+
const e = q(s), o = { ...yt(e.search), ...t };
|
|
77
|
+
return e.search = Lt(o), X(e);
|
|
78
|
+
}
|
|
79
|
+
function At(s) {
|
|
80
|
+
return !s || s === "/";
|
|
81
|
+
}
|
|
82
|
+
function Ft(s) {
|
|
83
|
+
return s && s !== "/";
|
|
84
|
+
}
|
|
85
|
+
function j(s, ...t) {
|
|
86
|
+
let e = s || "";
|
|
87
|
+
for (const o of t.filter((a) => Ft(a)))
|
|
88
|
+
if (e) {
|
|
89
|
+
const a = o.replace(zt, "");
|
|
90
|
+
e = Bt(e) + a;
|
|
91
|
+
} else
|
|
92
|
+
e = o;
|
|
93
|
+
return e;
|
|
94
|
+
}
|
|
95
|
+
function $t(s, t) {
|
|
96
|
+
return F(v(s)) === F(v(t));
|
|
97
|
+
}
|
|
98
|
+
function Wt(s, t) {
|
|
99
|
+
if (!t || t === "#")
|
|
100
|
+
return s;
|
|
101
|
+
const e = q(s);
|
|
102
|
+
return e.hash = t === "" ? "" : "#" + mt(t), X(e);
|
|
103
|
+
}
|
|
104
|
+
const V = /* @__PURE__ */ Symbol.for("ufo:protocolRelative");
|
|
105
|
+
function q(s = "", t) {
|
|
106
|
+
const e = s.match(
|
|
107
|
+
/^[\s\0]*(blob:|data:|javascript:|vbscript:)(.*)/i
|
|
108
|
+
);
|
|
109
|
+
if (e) {
|
|
110
|
+
const [, d, P = ""] = e;
|
|
111
|
+
return {
|
|
112
|
+
protocol: d.toLowerCase(),
|
|
113
|
+
pathname: P,
|
|
114
|
+
href: d + P,
|
|
115
|
+
auth: "",
|
|
116
|
+
host: "",
|
|
117
|
+
search: "",
|
|
118
|
+
hash: ""
|
|
119
|
+
};
|
|
120
|
+
}
|
|
121
|
+
if (!W(s, { acceptRelative: !0 }))
|
|
122
|
+
return E(s);
|
|
123
|
+
const [, o = "", a, n = ""] = s.replace(/\\/g, "/").match(/^[\s\0]*([\w+.-]{2,}:)?\/\/([^/@]+@)?(.*)/) || [];
|
|
124
|
+
let [, r = "", l = ""] = n.match(/([^#/?]*)(.*)?/) || [];
|
|
125
|
+
o === "file:" && (l = l.replace(/\/(?=[A-Za-z]:)/, ""));
|
|
126
|
+
const { pathname: c, search: u, hash: m } = E(l);
|
|
127
|
+
return {
|
|
128
|
+
protocol: o.toLowerCase(),
|
|
129
|
+
auth: a ? a.slice(0, Math.max(0, a.length - 1)) : "",
|
|
130
|
+
host: r,
|
|
131
|
+
pathname: c,
|
|
132
|
+
search: u,
|
|
133
|
+
hash: m,
|
|
134
|
+
[V]: !o
|
|
135
|
+
};
|
|
136
|
+
}
|
|
137
|
+
function E(s = "") {
|
|
138
|
+
const [t = "", e = "", o = ""] = (s.match(/([^#?]*)(\?[^#]*)?(#.*)?/) || []).splice(1);
|
|
139
|
+
return {
|
|
140
|
+
pathname: t,
|
|
141
|
+
search: e,
|
|
142
|
+
hash: o
|
|
143
|
+
};
|
|
144
|
+
}
|
|
145
|
+
function X(s) {
|
|
146
|
+
const t = s.pathname || "", e = s.search ? (s.search.startsWith("?") ? "" : "?") + s.search : "", o = s.hash || "", a = s.auth ? s.auth + "@" : "", n = s.host || "";
|
|
147
|
+
return (s.protocol || s[V] ? (s.protocol || "") + "//" : "") + a + n + t + e + o;
|
|
148
|
+
}
|
|
149
|
+
const Et = /\/([^/]+)$/;
|
|
150
|
+
function Ut(s = "", t) {
|
|
151
|
+
const { pathname: e } = q(s), o = e.match(Et);
|
|
152
|
+
return o ? o[1] : void 0;
|
|
153
|
+
}
|
|
154
|
+
function J(s) {
|
|
155
|
+
return (E(s.startsWith("/") ? s : `/${s}`).pathname || "").split("/").filter(Boolean);
|
|
156
|
+
}
|
|
157
|
+
const y = (s) => At(s ?? "") ? "/" : K(v(M(s))) || "/";
|
|
158
|
+
function jt(s) {
|
|
159
|
+
const t = M(s || "/");
|
|
160
|
+
return v(t) || "/";
|
|
161
|
+
}
|
|
162
|
+
function g(...s) {
|
|
163
|
+
const t = s.filter((n) => typeof n == "string" && n !== "");
|
|
164
|
+
if (t.length === 0) return "/";
|
|
165
|
+
const [e, ...o] = t, a = j(e, ...o) || "/";
|
|
166
|
+
return W(a) ? a : K(a);
|
|
167
|
+
}
|
|
168
|
+
function Y(s) {
|
|
169
|
+
return s && E(s).pathname || "";
|
|
170
|
+
}
|
|
171
|
+
function I(s, t, e) {
|
|
172
|
+
let o = St(s, t ?? {});
|
|
173
|
+
if (e && e !== "#") {
|
|
174
|
+
const a = e.startsWith("#") ? e.slice(1) : e;
|
|
175
|
+
o = Wt(o, a);
|
|
176
|
+
}
|
|
177
|
+
return o;
|
|
178
|
+
}
|
|
179
|
+
function N(s) {
|
|
180
|
+
if (!s) return "";
|
|
181
|
+
let t = "";
|
|
182
|
+
for (let e = 0; e < s.length; e++)
|
|
183
|
+
t += s[e] === "-" ? "/" : s[e];
|
|
184
|
+
return t;
|
|
185
|
+
}
|
|
186
|
+
function Z(s) {
|
|
187
|
+
if (!s) return "";
|
|
188
|
+
const t = s.indexOf("-");
|
|
189
|
+
return t === -1 ? s : j(s.slice(0, t), s.slice(t + 1));
|
|
190
|
+
}
|
|
191
|
+
function tt(s) {
|
|
192
|
+
if (!s) return "";
|
|
193
|
+
const t = s.lastIndexOf("-");
|
|
194
|
+
return t === -1 ? s : j(s.slice(0, t), s.slice(t + 1));
|
|
195
|
+
}
|
|
196
|
+
function qt(s) {
|
|
197
|
+
const t = J(s);
|
|
198
|
+
return t.length > 1 ? t.slice(0, -1).join("-") : "";
|
|
199
|
+
}
|
|
200
|
+
function Qt(s) {
|
|
201
|
+
return Ut(s || "/") ?? "";
|
|
202
|
+
}
|
|
203
|
+
function C(s, t) {
|
|
204
|
+
const e = s.name?.toString();
|
|
205
|
+
if (!e) return null;
|
|
206
|
+
const o = t.localizedRouteNamePrefix || "localized-", a = e.startsWith(o) ? e.slice(o.length) : e, n = [...t.locales].sort((r, l) => l.code.length - r.code.length);
|
|
207
|
+
for (const r of n) {
|
|
208
|
+
const l = `-${r.code}`;
|
|
209
|
+
if (!a.endsWith(l)) continue;
|
|
210
|
+
const c = a.length - r.code.length - 1;
|
|
211
|
+
if (c >= 0 && a[c] === "-")
|
|
212
|
+
return a.slice(0, -l.length);
|
|
213
|
+
}
|
|
214
|
+
return a;
|
|
215
|
+
}
|
|
216
|
+
function kt(s, t, e = "localized-") {
|
|
217
|
+
return `${e}${s}-${t}`;
|
|
218
|
+
}
|
|
219
|
+
function H(s, t) {
|
|
220
|
+
if (s == null) return !1;
|
|
221
|
+
const e = String(s).trim();
|
|
222
|
+
if (e === "" || e === "index") return !0;
|
|
223
|
+
const o = t?.localizedRouteNamePrefix ?? "localized-", a = t?.localeCodes ?? [], n = `${o}index-`;
|
|
224
|
+
if (!e.startsWith(n)) return !1;
|
|
225
|
+
const r = e.slice(n.length);
|
|
226
|
+
return a.length === 0 ? r.length >= 2 : a.includes(r);
|
|
227
|
+
}
|
|
228
|
+
function et(s, t) {
|
|
229
|
+
const e = Y(s), o = y(e);
|
|
230
|
+
if (o === "/")
|
|
231
|
+
return { pathWithoutLocale: "/", localeFromPath: null };
|
|
232
|
+
if (!U(o))
|
|
233
|
+
return { pathWithoutLocale: o, localeFromPath: null };
|
|
234
|
+
const a = o.indexOf("/", 1), n = a === -1 ? o.slice(1) : o.slice(1, a);
|
|
235
|
+
if (n && t.includes(n)) {
|
|
236
|
+
const r = 1 + n.length, l = o.slice(r);
|
|
237
|
+
return {
|
|
238
|
+
pathWithoutLocale: y(l || "/"),
|
|
239
|
+
localeFromPath: n
|
|
240
|
+
};
|
|
241
|
+
}
|
|
242
|
+
return { pathWithoutLocale: o, localeFromPath: null };
|
|
243
|
+
}
|
|
244
|
+
function _t(s, t) {
|
|
245
|
+
const e = Y(s);
|
|
246
|
+
if (e === "/" || e === "" || !U(e)) return null;
|
|
247
|
+
const o = e.indexOf("/", 1), a = o === -1 ? e.slice(1) : e.slice(1, o);
|
|
248
|
+
return a && t.includes(a) ? a : null;
|
|
249
|
+
}
|
|
250
|
+
function wt(s) {
|
|
251
|
+
return s.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
252
|
+
}
|
|
253
|
+
class Ct {
|
|
254
|
+
constructor(t) {
|
|
255
|
+
this.ctx = t;
|
|
256
|
+
}
|
|
257
|
+
/**
|
|
258
|
+
* Substitutes params into path template (:key, :key(), [...key]).
|
|
259
|
+
* Uses one combined regex per key to avoid creating multiple RegExp in a loop.
|
|
260
|
+
*/
|
|
261
|
+
resolvePathWithParams(t, e = {}) {
|
|
262
|
+
let o = t;
|
|
263
|
+
for (const a in e) {
|
|
264
|
+
const n = e[a];
|
|
265
|
+
if (n == null || n === "") continue;
|
|
266
|
+
const r = Array.isArray(n) ? n.join("/") : String(n), l = wt(a), c = new RegExp(
|
|
267
|
+
`:${l}\\(\\)|:${l}(?![\\w])|\\[\\.\\.\\.${l}\\]`,
|
|
268
|
+
"g"
|
|
269
|
+
);
|
|
270
|
+
o = o.replace(c, r);
|
|
271
|
+
}
|
|
272
|
+
return o;
|
|
273
|
+
}
|
|
274
|
+
/**
|
|
275
|
+
* Analyzes route: path without locale and base name (normalizer + route-name).
|
|
276
|
+
*/
|
|
277
|
+
analyzeRoute(t) {
|
|
278
|
+
const e = this.ctx.locales.map((n) => n.code), { pathWithoutLocale: o } = et(t.path || "/", e);
|
|
279
|
+
let a = null;
|
|
280
|
+
return t.name && (a = C(t, {
|
|
281
|
+
locales: this.ctx.locales,
|
|
282
|
+
localizedRouteNamePrefix: this.ctx.localizedRouteNamePrefix || "localized-"
|
|
283
|
+
})), { pathWithoutLocale: o, baseRouteName: a };
|
|
284
|
+
}
|
|
285
|
+
/** Public access to route analysis (for strategies). */
|
|
286
|
+
getPathWithoutLocaleAndBaseName(t) {
|
|
287
|
+
return this.analyzeRoute(t);
|
|
288
|
+
}
|
|
289
|
+
/**
|
|
290
|
+
* Lookup keys for config (same order for resolveCustomPath, getPathForUnlocalizedRoute, getAllowedLocalesForRoute).
|
|
291
|
+
*/
|
|
292
|
+
getLookupKeys(t, e) {
|
|
293
|
+
const o = [];
|
|
294
|
+
o.push(t);
|
|
295
|
+
const a = T(t);
|
|
296
|
+
if (a !== t && o.push(a), (t === "/" || a === "") && o.push(""), e) {
|
|
297
|
+
o.push(`/${e}`), o.push(e);
|
|
298
|
+
const n = N(e);
|
|
299
|
+
n && n !== e && o.push(n);
|
|
300
|
+
const r = Z(e);
|
|
301
|
+
r && o.push(r);
|
|
302
|
+
const l = tt(e);
|
|
303
|
+
l && o.push(l);
|
|
304
|
+
}
|
|
305
|
+
return o;
|
|
306
|
+
}
|
|
307
|
+
/**
|
|
308
|
+
* Resolves custom path for targetLocale from globalLocaleRoutes.
|
|
309
|
+
*/
|
|
310
|
+
resolveCustomPath(t, e) {
|
|
311
|
+
const o = this.ctx.globalLocaleRoutes;
|
|
312
|
+
if (!o || Object.keys(o).length === 0) return null;
|
|
313
|
+
const { pathWithoutLocale: a, baseRouteName: n } = this.analyzeRoute(t), r = this.getLookupKeys(a, n);
|
|
314
|
+
for (const l of r) {
|
|
315
|
+
const c = o[l];
|
|
316
|
+
if (c && typeof c == "object" && !Array.isArray(c)) {
|
|
317
|
+
const u = c[e];
|
|
318
|
+
if (typeof u == "string")
|
|
319
|
+
return this.resolvePathWithParams(u, t.params ?? {});
|
|
320
|
+
}
|
|
321
|
+
}
|
|
322
|
+
return null;
|
|
323
|
+
}
|
|
324
|
+
/**
|
|
325
|
+
* Unlocalized route (globalLocaleRoutes[key] === false) — returns path without locale.
|
|
326
|
+
*/
|
|
327
|
+
getPathForUnlocalizedRoute(t) {
|
|
328
|
+
const e = this.ctx.globalLocaleRoutes;
|
|
329
|
+
if (!e) return null;
|
|
330
|
+
const { pathWithoutLocale: o, baseRouteName: a } = this.analyzeRoute(t), n = this.getLookupKeys(o, a);
|
|
331
|
+
for (const r of n)
|
|
332
|
+
if (e[r] === !1) {
|
|
333
|
+
if (a && (r === a || r === `/${a}`)) {
|
|
334
|
+
const l = N(a);
|
|
335
|
+
return l ? g("/", l) : `/${a}`;
|
|
336
|
+
}
|
|
337
|
+
return o;
|
|
338
|
+
}
|
|
339
|
+
return null;
|
|
340
|
+
}
|
|
341
|
+
/**
|
|
342
|
+
* Unlocalized by name (when no route object available).
|
|
343
|
+
*/
|
|
344
|
+
getPathForUnlocalizedRouteByName(t) {
|
|
345
|
+
const e = this.ctx.globalLocaleRoutes;
|
|
346
|
+
if (!e) return null;
|
|
347
|
+
const o = [
|
|
348
|
+
t,
|
|
349
|
+
`/${t}`,
|
|
350
|
+
T(t)
|
|
351
|
+
];
|
|
352
|
+
for (const a of o)
|
|
353
|
+
if (e[a] === !1) {
|
|
354
|
+
const n = N(a.startsWith("/") ? a.slice(1) : a);
|
|
355
|
+
return n ? g("/", n) : a.startsWith("/") ? a : `/${a}`;
|
|
356
|
+
}
|
|
357
|
+
return null;
|
|
358
|
+
}
|
|
359
|
+
/**
|
|
360
|
+
* Allowed locales for route (routeLocales).
|
|
361
|
+
*/
|
|
362
|
+
getAllowedLocalesForRoute(t) {
|
|
363
|
+
const e = this.ctx.routeLocales;
|
|
364
|
+
if (!e || Object.keys(e).length === 0)
|
|
365
|
+
return this.ctx.locales.map((r) => r.code);
|
|
366
|
+
const { pathWithoutLocale: o, baseRouteName: a } = this.analyzeRoute(t);
|
|
367
|
+
let n = this.getLookupKeys(o, a);
|
|
368
|
+
a && this.ctx.routesLocaleLinks?.[a] && (n = [this.ctx.routesLocaleLinks[a], ...n]);
|
|
369
|
+
for (const r of n) {
|
|
370
|
+
const l = e[r];
|
|
371
|
+
if (Array.isArray(l) && l.length > 0)
|
|
372
|
+
return l.filter((c) => this.ctx.locales.some((u) => u.code === c));
|
|
373
|
+
}
|
|
374
|
+
return this.ctx.locales.map((r) => r.code);
|
|
375
|
+
}
|
|
376
|
+
/**
|
|
377
|
+
* Parent path for nested route (parent key -> targetLocale path).
|
|
378
|
+
*/
|
|
379
|
+
getParentPathForNested(t, e) {
|
|
380
|
+
if (t.length <= 1) return "/";
|
|
381
|
+
const o = t.length > 1 ? t.slice(0, -1).join("-") : "", a = this.ctx.globalLocaleRoutes;
|
|
382
|
+
if (o && a?.[o] && typeof a[o] == "object") {
|
|
383
|
+
const n = a[o];
|
|
384
|
+
if (n[e])
|
|
385
|
+
return y(n[e]);
|
|
386
|
+
}
|
|
387
|
+
return g("/", ...t.slice(0, -1));
|
|
388
|
+
}
|
|
389
|
+
}
|
|
390
|
+
class Ot {
|
|
391
|
+
constructor(t) {
|
|
392
|
+
this.ctx = t, this.resolver = new Ct(t);
|
|
393
|
+
}
|
|
394
|
+
setRouter(t) {
|
|
395
|
+
this.ctx.router = t;
|
|
396
|
+
}
|
|
397
|
+
getDefaultLocale() {
|
|
398
|
+
return this.ctx.defaultLocale;
|
|
399
|
+
}
|
|
400
|
+
getLocales() {
|
|
401
|
+
return this.ctx.locales;
|
|
402
|
+
}
|
|
403
|
+
getStrategy() {
|
|
404
|
+
return this.ctx.strategy;
|
|
405
|
+
}
|
|
406
|
+
getLocalizedRouteNamePrefix() {
|
|
407
|
+
return this.ctx.localizedRouteNamePrefix || "localized-";
|
|
408
|
+
}
|
|
409
|
+
getGlobalLocaleRoutes() {
|
|
410
|
+
return this.ctx.globalLocaleRoutes;
|
|
411
|
+
}
|
|
412
|
+
getRouteLocales() {
|
|
413
|
+
return this.ctx.routeLocales;
|
|
414
|
+
}
|
|
415
|
+
getRoutesLocaleLinks() {
|
|
416
|
+
return this.ctx.routesLocaleLinks;
|
|
417
|
+
}
|
|
418
|
+
getNoPrefixRedirect() {
|
|
419
|
+
return this.ctx.noPrefixRedirect;
|
|
420
|
+
}
|
|
421
|
+
/** Strips localization prefix/suffix and returns the "base" route name for one locale. */
|
|
422
|
+
getBaseRouteName(t, e) {
|
|
423
|
+
return C(t, {
|
|
424
|
+
locales: [{ code: e }],
|
|
425
|
+
localizedRouteNamePrefix: this.getLocalizedRouteNamePrefix()
|
|
426
|
+
});
|
|
427
|
+
}
|
|
428
|
+
/** Returns the base route name (without localized prefix/suffix) by trying all locales. */
|
|
429
|
+
getRouteBaseName(t) {
|
|
430
|
+
return C(t, {
|
|
431
|
+
locales: this.ctx.locales,
|
|
432
|
+
localizedRouteNamePrefix: this.getLocalizedRouteNamePrefix()
|
|
433
|
+
});
|
|
434
|
+
}
|
|
435
|
+
/** Resolves target path for a locale, checking globalLocaleRoutes first. */
|
|
436
|
+
resolvePathForLocale(t, e) {
|
|
437
|
+
const o = {
|
|
438
|
+
path: t,
|
|
439
|
+
name: null,
|
|
440
|
+
fullPath: t,
|
|
441
|
+
params: {}
|
|
442
|
+
}, a = this.resolver.resolveCustomPath(o, e);
|
|
443
|
+
return y(a || t);
|
|
444
|
+
}
|
|
445
|
+
buildLocalizedName(t, e) {
|
|
446
|
+
return kt(t, e, this.getLocalizedRouteNamePrefix());
|
|
447
|
+
}
|
|
448
|
+
getLocaleObject(t) {
|
|
449
|
+
return this.ctx.locales.find((e) => e.code === t);
|
|
450
|
+
}
|
|
451
|
+
applyBaseUrl(t, e) {
|
|
452
|
+
if (typeof e == "string") {
|
|
453
|
+
if (W(e)) return e;
|
|
454
|
+
} else if (e.path && W(e.path))
|
|
455
|
+
return e;
|
|
456
|
+
const o = this.getLocaleObject(t);
|
|
457
|
+
if (!o?.baseUrl)
|
|
458
|
+
return e;
|
|
459
|
+
const a = v(o.baseUrl);
|
|
460
|
+
if (typeof e == "string") {
|
|
461
|
+
const l = y(e.startsWith("/") ? e : `/${e}`);
|
|
462
|
+
return g(a, l);
|
|
463
|
+
}
|
|
464
|
+
const n = y(e.path || ""), r = g(a, n);
|
|
465
|
+
return {
|
|
466
|
+
...e,
|
|
467
|
+
path: r,
|
|
468
|
+
fullPath: r
|
|
469
|
+
};
|
|
470
|
+
}
|
|
471
|
+
/**
|
|
472
|
+
* Merges target route (strategy result) with query and hash from source route.
|
|
473
|
+
* Returns normalized RouteLike object.
|
|
474
|
+
*/
|
|
475
|
+
preserveQueryAndHash(t, e) {
|
|
476
|
+
if (!e || !e.query && !e.hash)
|
|
477
|
+
return t;
|
|
478
|
+
const o = typeof t == "string" ? { path: t } : { ...t };
|
|
479
|
+
e.query && (o.query = { ...e.query, ...o.query }), !o.hash && e.hash && (o.hash = e.hash);
|
|
480
|
+
const a = o.path ?? "";
|
|
481
|
+
return o.fullPath = I(a, o.query, o.hash), o;
|
|
482
|
+
}
|
|
483
|
+
resolvePathWithParams(t, e = {}) {
|
|
484
|
+
return this.resolver.resolvePathWithParams(t, e);
|
|
485
|
+
}
|
|
486
|
+
getPathWithoutLocaleAndBaseName(t) {
|
|
487
|
+
return this.resolver.getPathWithoutLocaleAndBaseName(t);
|
|
488
|
+
}
|
|
489
|
+
/** Look up custom path segment for targetLocale in globalLocaleRoutes. */
|
|
490
|
+
getCustomPathSegment(t, e) {
|
|
491
|
+
return this.resolver.resolveCustomPath(t, e);
|
|
492
|
+
}
|
|
493
|
+
getAllowedLocalesForRoute(t) {
|
|
494
|
+
return this.resolver.getAllowedLocalesForRoute(t);
|
|
495
|
+
}
|
|
496
|
+
getCanonicalPath(t, e) {
|
|
497
|
+
return null;
|
|
498
|
+
}
|
|
499
|
+
getPathForUnlocalizedRouteByName(t) {
|
|
500
|
+
return this.resolver.getPathForUnlocalizedRouteByName(t);
|
|
501
|
+
}
|
|
502
|
+
/**
|
|
503
|
+
* Try to resolve route by localized name. Returns RouteLike with query/hash from sourceRoute to preserve them.
|
|
504
|
+
*/
|
|
505
|
+
tryResolveByLocalizedName(t, e, o) {
|
|
506
|
+
const a = `${this.getLocalizedRouteNamePrefix()}${t}-${e}`, n = this.ctx.router.hasRoute(a);
|
|
507
|
+
if (this.debugLog("tryResolveByLocalizedName", { routeName: t, targetLocale: e, localizedName: a, hasRoute: n }), !n) return null;
|
|
508
|
+
const r = this.ctx.router.resolve({
|
|
509
|
+
name: a,
|
|
510
|
+
params: o?.params,
|
|
511
|
+
query: o?.query,
|
|
512
|
+
hash: o?.hash
|
|
513
|
+
});
|
|
514
|
+
return this.debugLog("tryResolveByLocalizedName resolved", { localizedName: a, path: r?.path, fullPath: r?.fullPath }), r?.path ? {
|
|
515
|
+
name: a,
|
|
516
|
+
path: r.path,
|
|
517
|
+
fullPath: r.fullPath,
|
|
518
|
+
params: r.params,
|
|
519
|
+
query: r.query ?? o?.query,
|
|
520
|
+
hash: r.hash ?? o?.hash
|
|
521
|
+
} : null;
|
|
522
|
+
}
|
|
523
|
+
/**
|
|
524
|
+
* Try to resolve route by localized name with params. Returns RouteLike to preserve query/hash.
|
|
525
|
+
*/
|
|
526
|
+
tryResolveByLocalizedNameWithParams(t, e, o, a) {
|
|
527
|
+
const n = `${this.getLocalizedRouteNamePrefix()}${t}-${e}`, r = this.ctx.router.hasRoute(n);
|
|
528
|
+
if (this.debugLog("tryResolveByLocalizedNameWithParams", { routeName: t, targetLocale: e, params: o, localizedName: n, hasRoute: r }), !r) return null;
|
|
529
|
+
const l = this.ctx.router.resolve({
|
|
530
|
+
name: n,
|
|
531
|
+
params: o,
|
|
532
|
+
query: a?.query,
|
|
533
|
+
hash: a?.hash
|
|
534
|
+
});
|
|
535
|
+
return this.debugLog("tryResolveByLocalizedNameWithParams resolved", { path: l?.path, fullPath: l?.fullPath }), !l?.path || l.path === "/" ? null : {
|
|
536
|
+
name: n,
|
|
537
|
+
path: l.path,
|
|
538
|
+
fullPath: l.fullPath,
|
|
539
|
+
params: l.params,
|
|
540
|
+
query: l.query ?? a?.query,
|
|
541
|
+
hash: l.hash ?? a?.hash
|
|
542
|
+
};
|
|
543
|
+
}
|
|
544
|
+
getPathForUnlocalizedRoute(t) {
|
|
545
|
+
return this.resolver.getPathForUnlocalizedRoute(t);
|
|
546
|
+
}
|
|
547
|
+
/**
|
|
548
|
+
* Builds localized path from baseName + params when router does not have the route.
|
|
549
|
+
* Tries two conventions:
|
|
550
|
+
* 1) Hyphen form (Nuxt test-[id].vue → /test-:id): when single param key equals last baseName segment (e.g. test-id + id → test-:id).
|
|
551
|
+
* 2) Slash form (kebab→slash): path segments from baseName, last N replaced by :paramKey (e.g. test-id → /test/:id).
|
|
552
|
+
*/
|
|
553
|
+
buildPathFromBaseNameAndParams(t, e, o) {
|
|
554
|
+
const a = Object.keys(e).filter((m) => e[m] !== void 0 && e[m] !== null && e[m] !== "");
|
|
555
|
+
if (a.length === 0) return null;
|
|
556
|
+
let n;
|
|
557
|
+
const r = a[0];
|
|
558
|
+
if (a.length === 1 && r !== void 0 && t.endsWith("-" + r))
|
|
559
|
+
n = g("/", t.slice(0, t.length - r.length - 1) + "-:" + r);
|
|
560
|
+
else {
|
|
561
|
+
const m = N(t), d = m ? m.split("/").filter(Boolean) : [t], P = Math.min(a.length, d.length), R = d.slice(0, d.length - P).concat(a.slice(0, P).map((B) => `:${B}`));
|
|
562
|
+
n = g("/", ...R);
|
|
563
|
+
}
|
|
564
|
+
const l = this.resolvePathWithParams(n, e), c = this.buildLocalizedPath(l, o, !1), u = this.applyBaseUrl(o, c);
|
|
565
|
+
return typeof u == "string" ? u : u.path ?? c;
|
|
566
|
+
}
|
|
567
|
+
getPathWithoutLocale(t) {
|
|
568
|
+
return et(t, this.ctx.locales.map((e) => e.code));
|
|
569
|
+
}
|
|
570
|
+
getLocaleFromPath(t) {
|
|
571
|
+
return _t(t, this.ctx.locales.map((e) => e.code));
|
|
572
|
+
}
|
|
573
|
+
/**
|
|
574
|
+
* Builds SEO attributes (canonical + hreflangs) from current route.
|
|
575
|
+
* Respects routeLocales: only allowed locales for this route get an hreflang entry.
|
|
576
|
+
* routesLocaleLinks is used when resolving the route key for routeLocales lookup.
|
|
577
|
+
*/
|
|
578
|
+
getSeoAttributes(t) {
|
|
579
|
+
const e = this.resolveLocaleFromPath(t.path) ?? this.ctx.defaultLocale, o = this.getCanonicalPath(t, e) ?? t.path, a = this.buildFullUrl(e, o), n = this.getAllowedLocalesForRoute(t), l = this.ctx.locales.filter((c) => n.includes(c.code)).map((c) => {
|
|
580
|
+
const u = this.localeRoute(c.code, t, t), d = (u.path ?? u.fullPath ?? "") || "/";
|
|
581
|
+
return {
|
|
582
|
+
rel: "alternate",
|
|
583
|
+
hreflang: c.code,
|
|
584
|
+
href: this.buildFullUrl(c.code, d)
|
|
585
|
+
};
|
|
586
|
+
});
|
|
587
|
+
return { canonical: a, hreflangs: l };
|
|
588
|
+
}
|
|
589
|
+
/**
|
|
590
|
+
* Builds full URL (path + optional baseUrl for locale).
|
|
591
|
+
*/
|
|
592
|
+
buildFullUrl(t, e) {
|
|
593
|
+
const o = this.applyBaseUrl(t, e);
|
|
594
|
+
return typeof o == "string" ? o : o.path ?? e;
|
|
595
|
+
}
|
|
596
|
+
/** When router knows neither targetName nor baseName — what to return (strategy may override). */
|
|
597
|
+
getSwitchLocaleFallbackWhenNoRoute(t, e) {
|
|
598
|
+
return { ...t, name: e };
|
|
599
|
+
}
|
|
600
|
+
/**
|
|
601
|
+
* Default: baseName → buildLocalizedRouteName → hasRoute → applyBaseUrl; fallback to baseName.
|
|
602
|
+
*/
|
|
603
|
+
switchLocaleRoute(t, e, o, a) {
|
|
604
|
+
const n = this.getBaseRouteName(o, t);
|
|
605
|
+
if (!n) return o;
|
|
606
|
+
let r = this.buildLocalizedRouteName(n, e);
|
|
607
|
+
if (!this.ctx.router.hasRoute(r))
|
|
608
|
+
if (this.ctx.router.hasRoute(n))
|
|
609
|
+
r = n;
|
|
610
|
+
else
|
|
611
|
+
return this.getSwitchLocaleFallbackWhenNoRoute(o, r);
|
|
612
|
+
const l = a.i18nRouteParams?.[e] || {}, c = { ...o.params || {}, ...l };
|
|
613
|
+
delete c.locale;
|
|
614
|
+
const u = {
|
|
615
|
+
name: r,
|
|
616
|
+
params: c,
|
|
617
|
+
query: o.query,
|
|
618
|
+
hash: o.hash
|
|
619
|
+
};
|
|
620
|
+
return this.applyBaseUrl(e, u);
|
|
621
|
+
}
|
|
622
|
+
/**
|
|
623
|
+
* Template Method: BaseStrategy knows "how" (normalize → delegate to strategy).
|
|
624
|
+
* Always returns RouteLike with path and fullPath (never a string).
|
|
625
|
+
*/
|
|
626
|
+
localeRoute(t, e, o) {
|
|
627
|
+
const a = this.normalizeRouteInput(e, o), n = this.resolveLocaleRoute(t, a, o);
|
|
628
|
+
this.debugLog("localeRoute raw", { rawPath: typeof n == "string" ? n : n.path, rawFullPath: typeof n == "string" ? n : n.fullPath });
|
|
629
|
+
const r = this.ensureRouteLike(n, a.kind === "route" ? a.sourceRoute : void 0);
|
|
630
|
+
return this.debugLog("localeRoute after ensureRouteLike", { path: r.path, fullPath: r.fullPath }), r;
|
|
631
|
+
}
|
|
632
|
+
/** Normalizes resolveLocaleRoute result into RouteLike (path and fullPath always set). */
|
|
633
|
+
ensureRouteLike(t, e) {
|
|
634
|
+
if (typeof t == "string") {
|
|
635
|
+
const n = t, r = e?.query || e?.hash ? I(n, e?.query, e?.hash) : n;
|
|
636
|
+
return {
|
|
637
|
+
path: n,
|
|
638
|
+
fullPath: r,
|
|
639
|
+
...e?.query && { query: e.query },
|
|
640
|
+
...e?.hash && { hash: e.hash }
|
|
641
|
+
};
|
|
642
|
+
}
|
|
643
|
+
let o = t.fullPath ?? t.path ?? "", a = t.path ?? o.split("?")[0]?.split("#")[0] ?? o;
|
|
644
|
+
if (!a && !o) {
|
|
645
|
+
const n = t.name?.toString() ?? e?.name?.toString() ?? "";
|
|
646
|
+
H(n, {
|
|
647
|
+
localizedRouteNamePrefix: this.getLocalizedRouteNamePrefix(),
|
|
648
|
+
localeCodes: this.ctx.locales.map((r) => r.code)
|
|
649
|
+
}) && (a = "/", o = "/");
|
|
650
|
+
}
|
|
651
|
+
return { ...t, path: a, fullPath: o };
|
|
652
|
+
}
|
|
653
|
+
/**
|
|
654
|
+
* Normalizes localeRoute input into a single structure (path string or route with resolved).
|
|
655
|
+
*/
|
|
656
|
+
normalizeRouteInput(t, e) {
|
|
657
|
+
if (typeof t == "string")
|
|
658
|
+
return { kind: "path", path: t };
|
|
659
|
+
const o = t, a = o.name?.toString() ?? null;
|
|
660
|
+
let n;
|
|
661
|
+
try {
|
|
662
|
+
n = this.ctx.router.resolve(t), this.debugLog("normalizeRouteInput router.resolve ok", { inputName: a, resolvedPath: n.path, resolvedName: n.name });
|
|
663
|
+
} catch {
|
|
664
|
+
n = {
|
|
665
|
+
name: a,
|
|
666
|
+
path: o.path ?? "/",
|
|
667
|
+
fullPath: o.fullPath ?? o.path ?? "/",
|
|
668
|
+
params: o.params ?? {},
|
|
669
|
+
query: o.query ?? {},
|
|
670
|
+
hash: o.hash ?? ""
|
|
671
|
+
}, this.debugLog("normalizeRouteInput router.resolve catch fallback", { inputName: a, resolvedPath: n.path });
|
|
672
|
+
}
|
|
673
|
+
return { kind: "route", inputName: a, sourceRoute: o, resolved: n };
|
|
674
|
+
}
|
|
675
|
+
/** Logging when ctx.debug (for localeRoute debugging). Disabled by default. */
|
|
676
|
+
debugLog(...t) {
|
|
677
|
+
}
|
|
678
|
+
/**
|
|
679
|
+
* Default resolution: uses buildLocalizedPath and buildLocalizedRouteName.
|
|
680
|
+
* Strategies with different logic (e.g. prefix-except-default) override this method.
|
|
681
|
+
*/
|
|
682
|
+
resolveLocaleRoute(t, e, o) {
|
|
683
|
+
if (e.kind === "path") {
|
|
684
|
+
const i = this.resolvePathForLocale(e.path, t), h = this.buildLocalizedPath(i, t, !1), f = this.applyBaseUrl(t, h);
|
|
685
|
+
return this.debugLog("branch=path", { targetLocale: t, path: e.path, finalPath: h, out: typeof f == "string" ? f : f.path }), f;
|
|
686
|
+
}
|
|
687
|
+
const { inputName: a, sourceRoute: n, resolved: r } = e, l = n.params && Object.keys(n.params ?? {}).length > 0, c = this.getRouteBaseName(r) ?? a ?? r.name?.toString() ?? null, u = r.name?.toString();
|
|
688
|
+
if (this.debugLog("input", { targetLocale: t, inputName: a, resolvedPath: r.path, resolvedName: r.name, params: n.params, hasParams: l, baseName: c }), a) {
|
|
689
|
+
const i = this.getPathForUnlocalizedRouteByName(a);
|
|
690
|
+
if (i !== null)
|
|
691
|
+
return this.debugLog("branch=unlocalizedByName", { inputName: a, unlocalizedByName: i }), this.preserveQueryAndHash(i, n);
|
|
692
|
+
}
|
|
693
|
+
if (a && l) {
|
|
694
|
+
const i = this.tryResolveByLocalizedNameWithParams(
|
|
695
|
+
a,
|
|
696
|
+
t,
|
|
697
|
+
n.params ?? {},
|
|
698
|
+
n
|
|
699
|
+
);
|
|
700
|
+
if (i !== null)
|
|
701
|
+
return this.debugLog("branch=routeWithParams", { inputName: a, path: i.path, fullPath: i.fullPath }), this.preserveQueryAndHash(this.applyBaseUrl(t, i), n);
|
|
702
|
+
}
|
|
703
|
+
if (a && !l) {
|
|
704
|
+
let i = this.tryResolveByLocalizedName(a, t, n);
|
|
705
|
+
const h = this.getLocalizedRouteNamePrefix();
|
|
706
|
+
if (i === null && c != null && c !== a && a.startsWith(h) && (i = this.tryResolveByLocalizedName(c, t, n)), i !== null)
|
|
707
|
+
return this.debugLog("branch=routeByLocalizedName", { inputName: a, path: i.path, fullPath: i.fullPath }), this.preserveQueryAndHash(this.applyBaseUrl(t, i), n);
|
|
708
|
+
}
|
|
709
|
+
const m = this.getPathForUnlocalizedRoute(r);
|
|
710
|
+
if (m !== null) {
|
|
711
|
+
const i = this.buildLocalizedPath(m, t, !1);
|
|
712
|
+
return this.debugLog("branch=unlocalizedPath", { unlocalizedPath: m, path: i }), this.preserveQueryAndHash(this.applyBaseUrl(t, i), n);
|
|
713
|
+
}
|
|
714
|
+
const d = this.getCustomPathSegment(r, t);
|
|
715
|
+
if (d !== null) {
|
|
716
|
+
const i = r.name?.toString() ?? a ?? "", h = i ? Z(i) : "", f = i ? tt(i) : "", p = this.ctx.globalLocaleRoutes, x = h.includes("/") && p?.[h], b = f.includes("/") && p?.[f], st = x || b, at = b ? f : h;
|
|
717
|
+
let A;
|
|
718
|
+
if (st) {
|
|
719
|
+
const k = J(at), z = k.length > 1 ? k.slice(0, -1).join("-") : "", O = z && p?.[z] && typeof p[z] == "object" && !Array.isArray(p[z]) ? p[z] : null, ot = O?.[t] ? y(O[t]) : g("/", ...k.slice(0, -1)), nt = d.startsWith("/") ? d.slice(1) : d;
|
|
720
|
+
A = g(ot, nt);
|
|
721
|
+
} else
|
|
722
|
+
A = y(d);
|
|
723
|
+
const Q = this.buildLocalizedPath(A, t, !0);
|
|
724
|
+
return this.debugLog("branch=customSegment", { customSegment: d, pathWithoutLocale: A, finalPath: Q }), this.preserveQueryAndHash(this.applyBaseUrl(t, Q), n);
|
|
725
|
+
}
|
|
726
|
+
const P = c ?? a;
|
|
727
|
+
if (this.debugLog("before effectiveBaseName check", { baseName: c, inputName: a, effectiveBaseName: P, resolvedName: r.name?.toString() }), !P)
|
|
728
|
+
return this.debugLog("branch=noBaseName", { return: "src" }), n;
|
|
729
|
+
if (!l && r.path && r.path !== "/" && r.name) {
|
|
730
|
+
const { pathWithoutLocale: i, baseRouteName: h } = this.getPathWithoutLocaleAndBaseName(r);
|
|
731
|
+
if (i && i !== "/") {
|
|
732
|
+
const f = h && i === h ? g("/", N(h)) : i, p = this.buildLocalizedPath(f, t, !1);
|
|
733
|
+
return this.debugLog("branch=pathFromResolved", { pathWithoutLocale: i, baseRouteName: h, pathToUse: f, finalPath: p }), this.preserveQueryAndHash(this.applyBaseUrl(t, p), n);
|
|
734
|
+
}
|
|
735
|
+
}
|
|
736
|
+
const R = u === a ? P : a ?? P;
|
|
737
|
+
this.debugLog("fallback build", { resolvedNameStr: u, inputName: a, baseNameForPath: R, targetLocale: t, hasParams: l });
|
|
738
|
+
const B = this.buildLocalizedRouteName(R, t), L = {
|
|
739
|
+
...n,
|
|
740
|
+
name: B,
|
|
741
|
+
params: { ...n.params }
|
|
742
|
+
};
|
|
743
|
+
if (l) {
|
|
744
|
+
let i = null;
|
|
745
|
+
try {
|
|
746
|
+
const h = this.ctx.router.resolve({ name: R, params: n.params });
|
|
747
|
+
if (h?.path) {
|
|
748
|
+
const f = h.path === "/" ? "/" : (() => {
|
|
749
|
+
const { pathWithoutLocale: b } = this.getPathWithoutLocale(h.path);
|
|
750
|
+
return b && b !== "/" ? b : h.path;
|
|
751
|
+
})(), p = this.buildLocalizedPath(f, t, !1), x = this.applyBaseUrl(t, p);
|
|
752
|
+
i = typeof x == "string" ? x : x.path ?? p;
|
|
753
|
+
}
|
|
754
|
+
} catch {
|
|
755
|
+
i = this.buildPathFromBaseNameAndParams(R, n.params ?? {}, t);
|
|
756
|
+
}
|
|
757
|
+
i && (L.path = i, L.fullPath = i);
|
|
758
|
+
} else {
|
|
759
|
+
const i = H(R) ? "/" : g("/", N(R)), h = this.buildLocalizedPath(i, t, !1), f = this.applyBaseUrl(t, h), p = typeof f == "string" ? f : f.path ?? h;
|
|
760
|
+
this.debugLog("fallback !hasParams", { pathWithoutLocale: i, finalPath: h, pathStr: p }), L.path = p, L.fullPath = p;
|
|
761
|
+
}
|
|
762
|
+
const S = this.preserveQueryAndHash(this.applyBaseUrl(t, L), n);
|
|
763
|
+
return this.debugLog("branch=fallbackNewRoute return", { baseName: c, targetName: B, hasParams: l, newRoutePath: L.path, outPath: typeof S == "string" ? S : S.path }), S;
|
|
764
|
+
}
|
|
765
|
+
}
|
|
766
|
+
export {
|
|
767
|
+
Ot as B,
|
|
768
|
+
Ct as R,
|
|
769
|
+
jt as a,
|
|
770
|
+
tt as b,
|
|
771
|
+
M as c,
|
|
772
|
+
H as d,
|
|
773
|
+
Z as e,
|
|
774
|
+
J as f,
|
|
775
|
+
Y as g,
|
|
776
|
+
K as h,
|
|
777
|
+
$t as i,
|
|
778
|
+
g as j,
|
|
779
|
+
I as k,
|
|
780
|
+
Qt as l,
|
|
781
|
+
kt as m,
|
|
782
|
+
y as n,
|
|
783
|
+
_t as o,
|
|
784
|
+
qt as p,
|
|
785
|
+
et as q,
|
|
786
|
+
C as r,
|
|
787
|
+
N as t,
|
|
788
|
+
T as w
|
|
789
|
+
};
|
|
790
|
+
//# sourceMappingURL=base-strategy-DVqe8ehd.js.map
|