File tree Expand file tree Collapse file tree 2 files changed +10
-0
lines changed Expand file tree Collapse file tree 2 files changed +10
-0
lines changed Original file line number Diff line number Diff line change @@ -435,6 +435,9 @@ def map(self, path):
435
435
new = new .replace (sep (path ), sep (result ))
436
436
if not self .relative :
437
437
new = canonical_filename (new )
438
+ dot_start = result .startswith (("./" , ".\\ " )) and len (result ) > 2
439
+ if new .startswith (("./" , ".\\ " )) and not dot_start :
440
+ new = new [2 :]
438
441
self .debugfn (
439
442
f"Matched path { path !r} to rule { original_pattern !r} -> { result !r} , " +
440
443
f"producing { new !r} "
Original file line number Diff line number Diff line change @@ -380,6 +380,13 @@ def test_no_accidental_match(self, rel_yn):
380
380
aliases .add ('/home/*/src' , './mysrc' )
381
381
self .assert_unchanged (aliases , '/home/foo/srcetc' )
382
382
383
+ def test_no_dotslash (self , rel_yn ):
384
+ # The result shouldn't start with "./" if the map result didn't.
385
+ aliases = PathAliases (relative = rel_yn )
386
+ aliases .add ('*/project' , '.' )
387
+ # Because the map result has no slash, the actual result is os-dependent.
388
+ self .assert_mapped (aliases , '/ned/home/project/src/a.py' , f'src{ os .sep } a.py' )
389
+
383
390
def test_multiple_patterns (self , rel_yn ):
384
391
# also test the debugfn...
385
392
msgs = []
You can’t perform that action at this time.
0 commit comments