@@ -617,17 +617,33 @@ func (pt *Path) replaceMappedLocations(inputPath string) (string, string) {
617
617
return strings .NewReplacer ("<" , "<<>" , ">" , "<>>" ).Replace (path )
618
618
}
619
619
620
- for _ , key := range keys {
621
- if strings .HasPrefix (key , regexPrefix ) {
622
- input := strings .ReplaceAll (inputPath , `\` , `/` )
623
- match , OK := regex .FindStringMatch (key [len (regexPrefix ):], input , 1 )
624
- if ! OK {
625
- continue
626
- }
620
+ handleRegex := func (key string ) (string , bool ) {
621
+ if ! strings .HasPrefix (key , regexPrefix ) {
622
+ return "" , false
623
+ }
624
+
625
+ input := strings .ReplaceAll (inputPath , `\` , `/` )
626
+ pattern := key [len (regexPrefix ):]
627
+
628
+ // Add (?i) at the start of the pattern for case-insensitive matching on Windows
629
+ if pt .windowsPath || (pt .env .IsWsl () && strings .HasPrefix (input , "/mnt/" )) {
630
+ pattern = "(?i)" + pattern
631
+ }
627
632
628
- // Replace the first match with the mapped location.
629
- input = strings .Replace (input , match , pt .mappedLocations [key ], 1 )
630
- input = path .Clean (input )
633
+ match , OK := regex .FindStringMatch (pattern , input , 1 )
634
+ if ! OK {
635
+ return "" , false
636
+ }
637
+
638
+ // Replace the first match with the mapped location.
639
+ input = strings .Replace (input , match , pt .mappedLocations [key ], 1 )
640
+ input = path .Clean (input )
641
+
642
+ return input , true
643
+ }
644
+
645
+ for _ , key := range keys {
646
+ if input , OK := handleRegex (key ); OK {
631
647
return pt .parsePath (input )
632
648
}
633
649
0 commit comments