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.
Files changed (2) hide show
  1. package/MasterRouter.js +15 -3
  2. 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
- // Must be valid JavaScript identifier
412
- if (!/^[a-zA-Z_$][a-zA-Z0-9_$]*$/.test(name)) {
413
- throw new Error(`Invalid ${type} name: ${name}. Must be a valid identifier.`);
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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mastercontroller",
3
- "version": "1.3.15",
3
+ "version": "1.3.16",
4
4
  "description": "Fortune 500 ready Node.js MVC framework with enterprise security, monitoring, and horizontal scaling",
5
5
  "main": "MasterControl.js",
6
6
  "license": "MIT",