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', () => {
179
179
180
180
assert . deepStrictEqual ( actual , expected ) ;
181
181
} ) ;
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
+ } ) ;
182
192
} ) ;
183
193
184
194
describe ( '.convertPatternGroupsToTasks' , ( ) => {
Original file line number Diff line number Diff line change @@ -104,7 +104,13 @@ export function groupPatternsByBaseDirectory(patterns: Pattern[]): PatternsGroup
104
104
const group : PatternsGroup = { } ;
105
105
106
106
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 ) ;
108
114
109
115
if ( base in collection ) {
110
116
collection [ base ] . push ( pattern ) ;
Original file line number Diff line number Diff line change @@ -81,6 +81,13 @@ describe('Utils → Path', () => {
81
81
} ) ;
82
82
} ) ;
83
83
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
+
84
91
describe ( '.convertPathToPattern' , ( ) => {
85
92
it ( 'should return a pattern' , ( ) => {
86
93
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 {
42
42
return entry ;
43
43
}
44
44
45
+ export function removeBackslashes ( entry : string ) : string {
46
+ return entry . replaceAll ( '\\' , '' ) ;
47
+ }
48
+
45
49
export const escape = IS_WINDOWS_PLATFORM ? escapeWindowsPath : escapePosixPath ;
46
50
47
51
export function escapeWindowsPath ( pattern : Pattern ) : Pattern {
You can’t perform that action at this time.
0 commit comments