@@ -26,7 +26,9 @@ namespace vpath {
26
26
27
27
const invalidRootComponentRegExp = / ^ (? ! ( \/ | \/ \/ \w + \/ | [ a - z A - Z ] : \/ ? | ) $ ) / ;
28
28
const invalidNavigableComponentRegExp = / [: * ? " < > | ] / ;
29
+ const invalidNavigableComponentWithWildcardsRegExp = / [: " < > | ] / ;
29
30
const invalidNonNavigableComponentRegExp = / ^ \. { 1 , 2 } $ | [: * ? " < > | ] / ;
31
+ const invalidNonNavigableComponentWithWildcardsRegExp = / ^ \. { 1 , 2 } $ | [: " < > | ] / ;
30
32
const extRegExp = / \. \w + $ / ;
31
33
32
34
export const enum ValidationFlags {
@@ -44,6 +46,7 @@ namespace vpath {
44
46
AllowExtname = 1 << 8 ,
45
47
AllowTrailingSeparator = 1 << 9 ,
46
48
AllowNavigation = 1 << 10 ,
49
+ AllowWildcard = 1 << 11 ,
47
50
48
51
/** Path must be a valid directory root */
49
52
Root = RequireRoot | AllowRoot | AllowTrailingSeparator ,
@@ -63,7 +66,9 @@ namespace vpath {
63
66
const hasDirname = components . length > 2 ;
64
67
const hasBasename = components . length > 1 ;
65
68
const hasExtname = hasBasename && extRegExp . test ( components [ components . length - 1 ] ) ;
66
- const invalidComponentRegExp = flags & ValidationFlags . AllowNavigation ? invalidNavigableComponentRegExp : invalidNonNavigableComponentRegExp ;
69
+ const invalidComponentRegExp = flags & ValidationFlags . AllowNavigation
70
+ ? flags & ValidationFlags . AllowWildcard ? invalidNavigableComponentWithWildcardsRegExp : invalidNavigableComponentRegExp
71
+ : flags & ValidationFlags . AllowWildcard ? invalidNonNavigableComponentWithWildcardsRegExp : invalidNonNavigableComponentRegExp ;
67
72
68
73
// Validate required components
69
74
if ( flags & ValidationFlags . RequireRoot && ! hasRoot ) return false ;
0 commit comments