File tree Expand file tree Collapse file tree 4 files changed +28
-1
lines changed
Expand file tree Collapse file tree 4 files changed +28
-1
lines changed Original file line number Diff line number Diff line change @@ -179,6 +179,16 @@ describe('Managers → Task', () => {
179179
180180 assert . deepStrictEqual ( actual , expected ) ;
181181 } ) ;
182+
183+ it ( 'should remove backslashes from the base directory' , ( ) => {
184+ const expected : PatternsGroup = {
185+ "a'b" : [ String . raw `a\'b/*` ] ,
186+ } ;
187+
188+ const actual = manager . groupPatternsByBaseDirectory ( [ String . raw `a\'b/*` ] ) ;
189+
190+ assert . deepStrictEqual ( actual , expected ) ;
191+ } ) ;
182192 } ) ;
183193
184194 describe ( '.convertPatternGroupsToTasks' , ( ) => {
Original file line number Diff line number Diff line change @@ -104,7 +104,13 @@ export function groupPatternsByBaseDirectory(patterns: Pattern[]): PatternsGroup
104104 const group : PatternsGroup = { } ;
105105
106106 return patterns . reduce ( ( collection , pattern ) => {
107- const base = utils . pattern . getBaseDirectory ( pattern ) ;
107+ let base = utils . pattern . getBaseDirectory ( pattern ) ;
108+
109+ /**
110+ * After extracting the basic static part of the pattern, it becomes a path,
111+ * so escaping leads to referencing non-existent paths.
112+ */
113+ base = utils . path . removeBackslashes ( base ) ;
108114
109115 if ( base in collection ) {
110116 collection [ base ] . push ( pattern ) ;
Original file line number Diff line number Diff line change @@ -81,6 +81,13 @@ describe('Utils → Path', () => {
8181 } ) ;
8282 } ) ;
8383
84+ describe ( '.removeBackslashes' , ( ) => {
85+ it ( 'should return path without backslashes' , ( ) => {
86+ assert . strictEqual ( util . removeBackslashes ( String . raw `a\b` ) , 'ab' ) ;
87+ assert . strictEqual ( util . removeBackslashes ( String . raw `a\\\b` ) , String . raw `ab` ) ;
88+ } ) ;
89+ } ) ;
90+
8491 describe ( '.convertPathToPattern' , ( ) => {
8592 it ( 'should return a pattern' , ( ) => {
8693 assert . strictEqual ( util . convertPathToPattern ( '.{directory}' ) , String . raw `.\{directory\}` ) ;
Original file line number Diff line number Diff line change @@ -42,6 +42,10 @@ export function removeLeadingDotSegment(entry: string): string {
4242 return entry ;
4343}
4444
45+ export function removeBackslashes ( entry : string ) : string {
46+ return entry . replaceAll ( '\\' , '' ) ;
47+ }
48+
4549export const escape = IS_WINDOWS_PLATFORM ? escapeWindowsPath : escapePosixPath ;
4650
4751export function escapeWindowsPath ( pattern : Pattern ) : Pattern {
You can’t perform that action at this time.
0 commit comments