sv-router 0.14.0 → 0.14.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/package.json +13 -13
- package/src/helpers/match-route.js +4 -2
- package/src/helpers/preload.js +1 -0
- package/src/index.d.ts +6 -2
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "sv-router",
|
|
3
|
-
"version": "0.14.
|
|
3
|
+
"version": "0.14.1",
|
|
4
4
|
"description": "Modern Svelte Routing",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"svelte",
|
|
@@ -36,29 +36,29 @@
|
|
|
36
36
|
"esm-env": "^1.2.2"
|
|
37
37
|
},
|
|
38
38
|
"devDependencies": {
|
|
39
|
-
"@changesets/cli": "^2.
|
|
39
|
+
"@changesets/cli": "^2.30.0",
|
|
40
40
|
"@eslint/js": "^10.0.1",
|
|
41
|
-
"@sveltejs/vite-plugin-svelte": "^
|
|
41
|
+
"@sveltejs/vite-plugin-svelte": "^7.0.0",
|
|
42
42
|
"@testing-library/jest-dom": "^6.9.1",
|
|
43
43
|
"@testing-library/svelte": "^5.3.1",
|
|
44
44
|
"@testing-library/user-event": "^14.6.1",
|
|
45
|
-
"@types/node": "^24.
|
|
46
|
-
"eslint": "^10.0.
|
|
45
|
+
"@types/node": "^24.12.0",
|
|
46
|
+
"eslint": "^10.0.3",
|
|
47
47
|
"eslint-config-prettier": "^10.1.8",
|
|
48
48
|
"eslint-plugin-simple-import-sort": "^12.1.1",
|
|
49
|
-
"eslint-plugin-svelte": "^3.15.
|
|
49
|
+
"eslint-plugin-svelte": "^3.15.2",
|
|
50
50
|
"eslint-plugin-unicorn": "^63.0.0",
|
|
51
|
-
"globals": "^17.
|
|
52
|
-
"happy-dom": "^20.
|
|
51
|
+
"globals": "^17.4.0",
|
|
52
|
+
"happy-dom": "^20.8.4",
|
|
53
53
|
"prettier": "^3.8.1",
|
|
54
54
|
"prettier-plugin-jsdoc": "^1.8.0",
|
|
55
|
-
"prettier-plugin-svelte": "^3.
|
|
56
|
-
"svelte-check": "^4.
|
|
55
|
+
"prettier-plugin-svelte": "^3.5.1",
|
|
56
|
+
"svelte-check": "^4.4.5",
|
|
57
57
|
"type-testing": "^0.2.0",
|
|
58
58
|
"typescript": "^5.9.3",
|
|
59
|
-
"typescript-eslint": "^8.
|
|
60
|
-
"vite": "^
|
|
61
|
-
"vitest": "^4.0
|
|
59
|
+
"typescript-eslint": "^8.57.1",
|
|
60
|
+
"vite": "^8.0.0",
|
|
61
|
+
"vitest": "^4.1.0"
|
|
62
62
|
},
|
|
63
63
|
"peerDependencies": {
|
|
64
64
|
"svelte": "^5"
|
|
@@ -63,6 +63,8 @@ export function matchRoute(pathname, routes) {
|
|
|
63
63
|
}
|
|
64
64
|
|
|
65
65
|
const pathPart = pathParts[index];
|
|
66
|
+
const isLayoutGroup = routePart === '' && typeof routes['/'] !== 'function';
|
|
67
|
+
|
|
66
68
|
if (routePart.startsWith(':')) {
|
|
67
69
|
params[routePart.slice(1)] = decodeURIComponent(pathPart);
|
|
68
70
|
} else if (routePart.startsWith('*')) {
|
|
@@ -80,7 +82,7 @@ export function matchRoute(pathname, routes) {
|
|
|
80
82
|
);
|
|
81
83
|
match = /** @type {RouteComponent} */ (routes[resolvedPath]);
|
|
82
84
|
break outer;
|
|
83
|
-
} else if (routePart.toLowerCase() !== pathPart?.toLowerCase()) {
|
|
85
|
+
} else if (routePart.toLowerCase() !== pathPart?.toLowerCase() && !isLayoutGroup) {
|
|
84
86
|
break;
|
|
85
87
|
}
|
|
86
88
|
|
|
@@ -116,7 +118,7 @@ export function matchRoute(pathname, routes) {
|
|
|
116
118
|
continue;
|
|
117
119
|
}
|
|
118
120
|
|
|
119
|
-
const nestedPathname = '/' + pathParts.slice(index + 1).join('/');
|
|
121
|
+
const nestedPathname = isLayoutGroup ? pathname : '/' + pathParts.slice(index + 1).join('/');
|
|
120
122
|
const result = matchRoute(nestedPathname, routeMatch);
|
|
121
123
|
if (result.match) {
|
|
122
124
|
match = result.match;
|
package/src/helpers/preload.js
CHANGED
package/src/index.d.ts
CHANGED
|
@@ -324,6 +324,10 @@ type StripNonRoutes<T extends Routes> = {
|
|
|
324
324
|
: K]: T[K] extends Routes ? StripNonRoutes<T[K]> : T[K];
|
|
325
325
|
};
|
|
326
326
|
|
|
327
|
+
type NormalizeSlashes<T extends string> = T extends `${infer A}//${infer B}`
|
|
328
|
+
? NormalizeSlashes<`${A}/${B}`>
|
|
329
|
+
: T;
|
|
330
|
+
|
|
327
331
|
type RecursiveKeys<
|
|
328
332
|
T extends Routes,
|
|
329
333
|
Prefix extends string = '',
|
|
@@ -333,10 +337,10 @@ type RecursiveKeys<
|
|
|
333
337
|
? T[K] extends Routes
|
|
334
338
|
? RecursiveKeys<
|
|
335
339
|
T[K],
|
|
336
|
-
|
|
340
|
+
NormalizeSlashes<`${Prefix}${AnyParam extends true ? ReplaceParamWithString<K> : K}`>,
|
|
337
341
|
AnyParam
|
|
338
342
|
>
|
|
339
|
-
:
|
|
343
|
+
: NormalizeSlashes<`${Prefix}${AnyParam extends true ? ReplaceParamWithString<K> : K}`>
|
|
340
344
|
: never;
|
|
341
345
|
}[keyof T];
|
|
342
346
|
|