kempo-server 1.7.2 → 1.7.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/package.json +1 -1
  2. package/src/router.js +11 -8
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "kempo-server",
3
3
  "type": "module",
4
- "version": "1.7.2",
4
+ "version": "1.7.3",
5
5
  "description": "A lightweight, zero-dependency, file based routing server.",
6
6
  "main": "dist/index.js",
7
7
  "bin": {
package/src/router.js CHANGED
@@ -192,15 +192,18 @@ export default async (flags, log) => {
192
192
  // Helper function to resolve wildcard file paths
193
193
  const resolveWildcardPath = (filePath, matches) => {
194
194
  let resolvedPath = filePath;
195
+ let matchIndex = 1; // Start from matches[1] (first capture group)
195
196
 
196
- // Replace wildcards with captured values
197
- for (let i = 1; i < matches.length; i++) {
198
- // Replace ** first, then single *
199
- if (resolvedPath.includes('**')) {
200
- resolvedPath = resolvedPath.replace('**', matches[i]);
201
- } else {
202
- resolvedPath = resolvedPath.replace('*', matches[i]);
203
- }
197
+ // Replace ** wildcards first
198
+ while (resolvedPath.includes('**') && matchIndex < matches.length) {
199
+ resolvedPath = resolvedPath.replace('**', matches[matchIndex]);
200
+ matchIndex++;
201
+ }
202
+
203
+ // Replace any remaining * wildcards
204
+ while (resolvedPath.includes('*') && matchIndex < matches.length) {
205
+ resolvedPath = resolvedPath.replace('*', matches[matchIndex]);
206
+ matchIndex++;
204
207
  }
205
208
 
206
209
  // If the path is already absolute, return it as-is