From e0aca418bc0ae395c84ab770c33a7c019ced27cc Mon Sep 17 00:00:00 2001 From: Richard Knoll Date: Tue, 12 Jul 2016 11:13:35 -0700 Subject: [PATCH] Responding to PR feedback --- src/compiler/core.ts | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/compiler/core.ts b/src/compiler/core.ts index 895a325cca6..f913e6f9664 100644 --- a/src/compiler/core.ts +++ b/src/compiler/core.ts @@ -987,17 +987,17 @@ namespace ts { // The * and ? wildcards should not match directories or files that start with . if they // appear first in a component. Dotted directories and files can be included explicitly // like so: **/.*/.* - if (component.indexOf("*") === 0) { + if (component.charCodeAt(0) === CharacterCodes.asterisk) { subpattern += "([^./]" + singleAsteriskRegexFragment + ")?"; component = component.substr(1); } - else if (component.indexOf("?") === 0) { + else if (component.charCodeAt(0) === CharacterCodes.question) { subpattern += "[^./]"; component = component.substr(1); } } - subpattern += component.replace(reservedCharacterPattern, replaceWildcardCharacter); + subpattern += replaceWildcardCharacters(component, singleAsteriskRegexFragment); hasWrittenComponent = true; } } @@ -1020,6 +1020,10 @@ namespace ts { } return "^(" + pattern + (usage === "exclude" ? ")($|/)" : ")$"); + } + + function replaceWildcardCharacters(component: string, singleAsteriskRegexFragment: string) { + return component.replace(reservedCharacterPattern, replaceWildcardCharacter); function replaceWildcardCharacter(match: string) { return match === "*" ? singleAsteriskRegexFragment : match === "?" ? "[^/]" : "\\" + match;