Skip to content

Commit fc38cbf

Browse files
committed
Fix regression in canonicalizePath on Windows UNC paths
Fixes #170.
1 parent 9893189 commit fc38cbf

File tree

4 files changed

+17
-3
lines changed

4 files changed

+17
-3
lines changed

System/Directory/Internal/Windows.hsc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -356,7 +356,8 @@ fromExtendedLengthPath ePath' =
356356
| (toChar <$> [c1, c2, c3, c4]) == "\\\\?\\" ->
357357
case path of
358358
c5 : c6 : c7 : subpath@(c8 : _)
359-
| (toChar <$> [c5, c6, c7, c8]) == "UNC\\" -> pack subpath
359+
| (toChar <$> [c5, c6, c7, c8]) == "UNC\\" ->
360+
os "\\" <> pack subpath
360361
drive : col : subpath
361362
-- if the path is not "regular", then the prefix is necessary
362363
-- to ensure the path is interpreted literally

changelog.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
Changelog for the [`directory`][1] package
22
==========================================
33

4-
## 1.3.8.3 (TBD)
4+
## 1.3.8.3 (Jan 2024)
55

66
* Relax `Win32` version bounds to support 2.14.0.0.
77
([#166](https://github.com/haskell/directory/issues/166))
8+
* Fix regression in `canonicalizePath` on Windows UNC paths.
9+
([#170](https://github.com/haskell/directory/issues/170))
810

911
## 1.3.8.2 (Dec 2023)
1012

directory.cabal

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
cabal-version: 2.2
22
name: directory
3-
version: 1.3.8.2
3+
version: 1.3.8.3
44
license: BSD-3-Clause
55
license-file: LICENSE
66
maintainer: [email protected]

tests/CanonicalizePath.hs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,3 +160,14 @@ main _t = do
160160
vldn <- canonicalizePath "verylongdirectoryname"
161161
vldn2 <- canonicalizePath "VERYLONGDIRECTORYNAME"
162162
T(expectEq) () vldn vldn2
163+
164+
let isWindows =
165+
#if defined(mingw32_HOST_OS)
166+
True
167+
#else
168+
False
169+
#endif
170+
171+
when isWindows $ do
172+
-- https://github.com/haskell/directory/issues/170
173+
T(expectEq) () "\\\\localhost" =<< canonicalizePath "\\\\localhost"

0 commit comments

Comments
 (0)