File tree Expand file tree Collapse file tree 2 files changed +9
-3
lines changed Expand file tree Collapse file tree 2 files changed +9
-3
lines changed Original file line number Diff line number Diff line change @@ -984,6 +984,7 @@ makeRelative root path
984
984
-- > Posix: normalise "./bob/fred/" == "bob/fred/"
985
985
-- > Windows: normalise "c:\\file/bob\\" == "C:\\file\\bob\\"
986
986
-- > Windows: normalise "c:\\" == "C:\\"
987
+ -- > Windows: normalise "c:\\\\\\\\" == "C:\\"
987
988
-- > Windows: normalise "C:.\\" == "C:"
988
989
-- > Windows: normalise "\\\\server\\test" == "\\\\server\\test"
989
990
-- > Windows: normalise "//server/test" == "\\\\server\\test"
@@ -1035,9 +1036,12 @@ normaliseDrive :: FILEPATH -> FILEPATH
1035
1036
normaliseDrive bs
1036
1037
| null bs = mempty
1037
1038
| isPosix = pack [pathSeparator]
1038
- | otherwise = if isJust $ readDriveLetter x2
1039
- then map toUpper x2
1040
- else x2
1039
+ | Just (drv, _) <- readDriveLetter x2
1040
+ = case unpack drv of
1041
+ (x: _: [] ) -> pack [toUpper x, _colon]
1042
+ (x: _) -> pack [toUpper x, _colon, pathSeparator]
1043
+ _ -> P. error " impossible"
1044
+ | otherwise = x2
1041
1045
where
1042
1046
x2 = map repSlash bs
1043
1047
repSlash x = if isPathSeparator x then pathSeparator else x
Original file line number Diff line number Diff line change @@ -814,6 +814,8 @@ tests =
814
814
,(" AFP_W.normalise (\" c:\\\\ file/bob\\\\\" ) == (\" C:\\\\ file\\\\ bob\\\\\" )" , property $ AFP_W. normalise (" c:\\ file/bob\\ " ) == (" C:\\ file\\ bob\\ " ))
815
815
,(" W.normalise \" c:\\\\\" == \" C:\\\\\" " , property $ W. normalise " c:\\ " == " C:\\ " )
816
816
,(" AFP_W.normalise (\" c:\\\\\" ) == (\" C:\\\\\" )" , property $ AFP_W. normalise (" c:\\ " ) == (" C:\\ " ))
817
+ ,(" W.normalise \" c:\\\\\\\\\\\\\\\\\" == \" C:\\\\\" " , property $ W. normalise " c:\\\\\\\\ " == " C:\\ " )
818
+ ,(" AFP_W.normalise (\" c:\\\\\\\\\\\\\\\\\" ) == (\" C:\\\\\" )" , property $ AFP_W. normalise (" c:\\\\\\\\ " ) == (" C:\\ " ))
817
819
,(" W.normalise \" C:.\\\\\" == \" C:\" " , property $ W. normalise " C:.\\ " == " C:" )
818
820
,(" AFP_W.normalise (\" C:.\\\\\" ) == (\" C:\" )" , property $ AFP_W. normalise (" C:.\\ " ) == (" C:" ))
819
821
,(" W.normalise \"\\\\\\\\ server\\\\ test\" == \"\\\\\\\\ server\\\\ test\" " , property $ W. normalise " \\\\ server\\ test" == " \\\\ server\\ test" )
You can’t perform that action at this time.
0 commit comments