@pirxpilot/router 2.0.1 → 2.0.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.
Files changed (2) hide show
  1. package/lib/matcher.js +4 -4
  2. 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 parameterRegex = /:([a-zA-Z_]\w*)/g;
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 = new Set(pathname.matchAll(parameterRegex).map(m => m[1]));
54
+ const parameterOrder = Array.from(pathname.matchAll(PARAMETER_REGEXP), 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
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@pirxpilot/router",
3
3
  "description": "Simple middleware-style router",
4
- "version": "2.0.1",
4
+ "version": "2.0.3",
5
5
  "author": "Douglas Christopher Wilson <doug@somethingdoug.com>",
6
6
  "contributors": [
7
7
  "Blake Embrey <hello@blakeembrey.com>"