mastercontroller 1.3.15 → 1.3.16
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 +15 -3
- package/package.json +1 -1
package/MasterRouter.js
CHANGED
|
@@ -408,9 +408,21 @@ function validateIdentifier(name, type) {
|
|
|
408
408
|
throw new TypeError(`${type} name must be a non-empty string`);
|
|
409
409
|
}
|
|
410
410
|
|
|
411
|
-
//
|
|
412
|
-
|
|
413
|
-
|
|
411
|
+
// Controllers can have forward slashes for nested structures (e.g., "api/health")
|
|
412
|
+
// Actions must be simple identifiers
|
|
413
|
+
if (type === 'controller') {
|
|
414
|
+
// Split on slash and validate each segment
|
|
415
|
+
const segments = name.split('/');
|
|
416
|
+
for (const segment of segments) {
|
|
417
|
+
if (!segment || !/^[a-zA-Z_$][a-zA-Z0-9_$]*$/.test(segment)) {
|
|
418
|
+
throw new Error(`Invalid ${type} name: ${name}. Each segment must be a valid identifier.`);
|
|
419
|
+
}
|
|
420
|
+
}
|
|
421
|
+
} else {
|
|
422
|
+
// Actions must be simple identifiers (no slashes)
|
|
423
|
+
if (!/^[a-zA-Z_$][a-zA-Z0-9_$]*$/.test(name)) {
|
|
424
|
+
throw new Error(`Invalid ${type} name: ${name}. Must be a valid identifier.`);
|
|
425
|
+
}
|
|
414
426
|
}
|
|
415
427
|
}
|
|
416
428
|
|
package/package.json
CHANGED