mastercontroller 1.3.15 → 1.3.17
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/MasterRouter.js +21 -5
- package/package.json +1 -1
package/MasterRouter.js
CHANGED
|
@@ -89,7 +89,9 @@ const ROUTER_CONFIG = {
|
|
|
89
89
|
const sanitizedValue = sanitizeRouteParam(paramName, paramValue);
|
|
90
90
|
|
|
91
91
|
requestParams[paramName] = sanitizedValue;
|
|
92
|
-
|
|
92
|
+
// FIX: Use requestItem (original value) not sanitizedValue for route matching
|
|
93
|
+
// The route pattern should match against the actual request path
|
|
94
|
+
routePathList[i] = requestItem;
|
|
93
95
|
}
|
|
94
96
|
}
|
|
95
97
|
}
|
|
@@ -408,9 +410,21 @@ function validateIdentifier(name, type) {
|
|
|
408
410
|
throw new TypeError(`${type} name must be a non-empty string`);
|
|
409
411
|
}
|
|
410
412
|
|
|
411
|
-
//
|
|
412
|
-
|
|
413
|
-
|
|
413
|
+
// Controllers can have forward slashes for nested structures (e.g., "api/health")
|
|
414
|
+
// Actions must be simple identifiers
|
|
415
|
+
if (type === 'controller') {
|
|
416
|
+
// Split on slash and validate each segment
|
|
417
|
+
const segments = name.split('/');
|
|
418
|
+
for (const segment of segments) {
|
|
419
|
+
if (!segment || !/^[a-zA-Z_$][a-zA-Z0-9_$]*$/.test(segment)) {
|
|
420
|
+
throw new Error(`Invalid ${type} name: ${name}. Each segment must be a valid identifier.`);
|
|
421
|
+
}
|
|
422
|
+
}
|
|
423
|
+
} else {
|
|
424
|
+
// Actions must be simple identifiers (no slashes)
|
|
425
|
+
if (!/^[a-zA-Z_$][a-zA-Z0-9_$]*$/.test(name)) {
|
|
426
|
+
throw new Error(`Invalid ${type} name: ${name}. Must be a valid identifier.`);
|
|
427
|
+
}
|
|
414
428
|
}
|
|
415
429
|
}
|
|
416
430
|
|
|
@@ -903,7 +917,9 @@ class MasterRouter {
|
|
|
903
917
|
}
|
|
904
918
|
|
|
905
919
|
const $that = this;
|
|
906
|
-
|
|
920
|
+
// FIX: Use direct reference instead of Object.create() to preserve request/response objects
|
|
921
|
+
// Object.create() puts properties on prototype, causing undefined access issues
|
|
922
|
+
const requestObject = rr;
|
|
907
923
|
|
|
908
924
|
// CRITICAL FIX: Load scoped services into request-specific context
|
|
909
925
|
// Pass requestObject so scoped services are stored per-request, not globally
|
package/package.json
CHANGED