@sveltejs/kit 2.1.1 → 2.1.2
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/utils/routing.js +10 -2
- package/src/version.js +1 -1
package/package.json
CHANGED
package/src/utils/routing.js
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { BROWSER } from 'esm-env';
|
|
2
|
+
|
|
1
3
|
const param_pattern = /^(\[)?(\.\.\.)?(\w+)(?:=(\w+))?(\])?$/;
|
|
2
4
|
|
|
3
5
|
/**
|
|
@@ -62,9 +64,15 @@ export function parse_route_id(id) {
|
|
|
62
64
|
);
|
|
63
65
|
}
|
|
64
66
|
|
|
65
|
-
// We know the match cannot be null because manifest generation
|
|
66
|
-
// if we hit an invalid
|
|
67
|
+
// We know the match cannot be null in the browser because manifest generation
|
|
68
|
+
// would have invoked this during build and failed if we hit an invalid
|
|
69
|
+
// param/matcher name with non-alphanumeric character.
|
|
67
70
|
const match = /** @type {RegExpExecArray} */ (param_pattern.exec(content));
|
|
71
|
+
if (!BROWSER && !match) {
|
|
72
|
+
throw new Error(
|
|
73
|
+
`Invalid param: ${content}. Params and matcher names can only have underscores and alphanumeric characters.`
|
|
74
|
+
);
|
|
75
|
+
}
|
|
68
76
|
|
|
69
77
|
const [, is_optional, is_rest, name, matcher] = match;
|
|
70
78
|
// It's assumed that the following invalid route id cases are already checked
|
package/src/version.js
CHANGED