@sveltejs/kit 1.16.2 → 1.16.3
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 +1 -1
- package/src/runtime/client/client.js +2 -1
- package/src/utils/routing.js +18 -24
package/package.json
CHANGED
|
@@ -1908,7 +1908,8 @@ function reset_focus() {
|
|
|
1908
1908
|
const tabindex = root.getAttribute('tabindex');
|
|
1909
1909
|
|
|
1910
1910
|
root.tabIndex = -1;
|
|
1911
|
-
|
|
1911
|
+
// @ts-expect-error
|
|
1912
|
+
root.focus({ preventScroll: true, focusVisible: false });
|
|
1912
1913
|
|
|
1913
1914
|
// restore `tabindex` as to prevent `root` from stealing input from elements
|
|
1914
1915
|
if (tabindex !== null) {
|
package/src/utils/routing.js
CHANGED
|
@@ -96,7 +96,7 @@ export function parse_route_id(id) {
|
|
|
96
96
|
return { pattern, params };
|
|
97
97
|
}
|
|
98
98
|
|
|
99
|
-
const basic_param_pattern = /\[(\[)?(?:\.\.\.)?(\w+?)(?:=(\w+))?\]\]
|
|
99
|
+
const basic_param_pattern = /\[(\[)?(?:\.\.\.)?(\w+?)(?:=(\w+))?\]\]?/g;
|
|
100
100
|
|
|
101
101
|
/**
|
|
102
102
|
* Parses a route ID, then resolves it to a path by replacing parameters with actual values from `entry`.
|
|
@@ -112,29 +112,23 @@ export function resolve_entry(id, entry) {
|
|
|
112
112
|
return (
|
|
113
113
|
'/' +
|
|
114
114
|
segments
|
|
115
|
-
.map((segment) =>
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
throw new Error(
|
|
133
|
-
`Parameter '${name}' in route ${id} cannot start or end with a slash -- this would cause an invalid route like foo//bar`
|
|
134
|
-
);
|
|
135
|
-
|
|
136
|
-
return param_value;
|
|
137
|
-
})
|
|
115
|
+
.map((segment) =>
|
|
116
|
+
segment.replace(basic_param_pattern, (_, optional, name) => {
|
|
117
|
+
const param_value = entry[name];
|
|
118
|
+
|
|
119
|
+
// This is nested so TS correctly narrows the type
|
|
120
|
+
if (!param_value) {
|
|
121
|
+
if (optional) return '';
|
|
122
|
+
throw new Error(`Missing parameter '${name}' in route ${id}`);
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
if (param_value.startsWith('/') || param_value.endsWith('/'))
|
|
126
|
+
throw new Error(
|
|
127
|
+
`Parameter '${name}' in route ${id} cannot start or end with a slash -- this would cause an invalid route like foo//bar`
|
|
128
|
+
);
|
|
129
|
+
return param_value;
|
|
130
|
+
})
|
|
131
|
+
)
|
|
138
132
|
.filter(Boolean)
|
|
139
133
|
.join('/')
|
|
140
134
|
);
|