@@ -922,20 +922,22 @@ namespace ts {
922
922
const reservedCharacterPattern = / [ ^ \w \s \/ ] / g;
923
923
const wildcardCharCodes = [ CharacterCodes . asterisk , CharacterCodes . question ] ;
924
924
925
+ /**
926
+ * Matches any single directory segment unless it is the last segment and a .min.js file
927
+ * Breakdown:
928
+ * [^./] # matches everything up to the first . character (excluding directory seperators)
929
+ * (\\.(?!min\\.js$))? # matches . characters but not if they are part of the .min.js file extension
930
+ */
931
+ const singleAsteriskRegexFragmentFiles = "([^./]*(\\.(?!min\\.js$))?)*" ;
932
+ const singleAsteriskRegexFragmentOther = "[^/]*" ;
933
+
925
934
export function getRegularExpressionForWildcard ( specs : string [ ] , basePath : string , usage : "files" | "directories" | "exclude" ) {
926
935
if ( specs === undefined || specs . length === 0 ) {
927
936
return undefined ;
928
937
}
929
938
930
- /**
931
- * Regex for the * wildcard. Matches all characters except for directory seperators. When
932
- * used for including files, also does not match the file extension .min.js
933
- *
934
- * Breakdown for the "files" version:
935
- * [^./] # matches everything up to the first . character (excluding directory seperators)
936
- * (\\.(?!min\\.js$))? # matches . characters but not if they are part of the .min.js file extension
937
- */
938
- const singleAsteriskRegexFragment = usage === "files" ? "([^./]*(\\.(?!min\\.js$))?)*" : "[^/]*" ;
939
+ const replaceWildcardCharacter = usage === "files" ? replaceWildCardCharacterFiles : replaceWildCardCharacterOther ;
940
+ const singleAsteriskRegexFragment = usage === "files" ? singleAsteriskRegexFragmentFiles : singleAsteriskRegexFragmentOther ;
939
941
940
942
/**
941
943
* Regex for the ** wildcard. Matches any number of subdirectories. When used for including
@@ -997,7 +999,7 @@ namespace ts {
997
999
}
998
1000
}
999
1001
1000
- subpattern += replaceWildcardCharacters ( component , singleAsteriskRegexFragment ) ;
1002
+ subpattern += component . replace ( reservedCharacterPattern , replaceWildcardCharacter ) ;
1001
1003
hasWrittenComponent = true ;
1002
1004
}
1003
1005
}
@@ -1022,12 +1024,16 @@ namespace ts {
1022
1024
return "^(" + pattern + ( usage === "exclude" ? ")($|/)" : ")$" ) ;
1023
1025
}
1024
1026
1025
- function replaceWildcardCharacters ( component : string , singleAsteriskRegexFragment : string ) {
1026
- return component . replace ( reservedCharacterPattern , replaceWildcardCharacter ) ;
1027
+ function replaceWildCardCharacterFiles ( match : string ) {
1028
+ return replaceWildcardCharacter ( match , singleAsteriskRegexFragmentFiles ) ;
1029
+ }
1027
1030
1028
- function replaceWildcardCharacter ( match : string ) {
1029
- return match === "*" ? singleAsteriskRegexFragment : match === "?" ? "[^/]" : "\\" + match ;
1030
- }
1031
+ function replaceWildCardCharacterOther ( match : string ) {
1032
+ return replaceWildcardCharacter ( match , singleAsteriskRegexFragmentOther ) ;
1033
+ }
1034
+
1035
+ function replaceWildcardCharacter ( match : string , singleAsteriskRegexFragment : string ) {
1036
+ return match === "*" ? singleAsteriskRegexFragment : match === "?" ? "[^/]" : "\\" + match ;
1031
1037
}
1032
1038
1033
1039
export interface FileSystemEntries {
0 commit comments