@pirxpilot/router 2.0.1 → 2.0.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/lib/matcher.js +4 -4
- package/package.json +1 -1
package/lib/matcher.js
CHANGED
|
@@ -47,11 +47,11 @@ export function createRegexMatcher(path) {
|
|
|
47
47
|
};
|
|
48
48
|
}
|
|
49
49
|
|
|
50
|
-
const
|
|
50
|
+
const PARAMETER_REGEXP = /\/:([a-zA-Z_]\w*)/g;
|
|
51
51
|
|
|
52
52
|
export function createURLPatternMatcher(pathname, { sensitive, end, strict }) {
|
|
53
53
|
// Extract parameter names from the pattern in order
|
|
54
|
-
const parameterOrder =
|
|
54
|
+
const parameterOrder = pathname.matchAll(PARAMETER_REGEXP).map(m => m[1]);
|
|
55
55
|
|
|
56
56
|
// Build the pattern:
|
|
57
57
|
// - For end=false (prefix matching): add {/*}? to match optional trailing content
|
|
@@ -83,6 +83,8 @@ export function createURLPatternMatcher(pathname, { sensitive, end, strict }) {
|
|
|
83
83
|
if (value !== undefined) {
|
|
84
84
|
keys.push(key);
|
|
85
85
|
params[key] = decodeParam(value);
|
|
86
|
+
// mark as processed
|
|
87
|
+
match.pathname.groups[key] = undefined;
|
|
86
88
|
}
|
|
87
89
|
}
|
|
88
90
|
|
|
@@ -90,8 +92,6 @@ export function createURLPatternMatcher(pathname, { sensitive, end, strict }) {
|
|
|
90
92
|
for (const [key, value] of Object.entries(match.pathname.groups)) {
|
|
91
93
|
// Skip the default wildcard capture group '0'
|
|
92
94
|
if (key === '0') continue;
|
|
93
|
-
// Skip if we already processed this key
|
|
94
|
-
if (parameterOrder.has(key)) continue;
|
|
95
95
|
if (value !== undefined) {
|
|
96
96
|
keys.push(key);
|
|
97
97
|
params[key] = decodeParam(value);
|
package/package.json
CHANGED