diff --git a/System/Directory/Internal/Windows.hsc b/System/Directory/Internal/Windows.hsc index 1bc99c18..2696971d 100644 --- a/System/Directory/Internal/Windows.hsc +++ b/System/Directory/Internal/Windows.hsc @@ -356,7 +356,8 @@ fromExtendedLengthPath ePath' = | (toChar <$> [c1, c2, c3, c4]) == "\\\\?\\" -> case path of c5 : c6 : c7 : subpath@(c8 : _) - | (toChar <$> [c5, c6, c7, c8]) == "UNC\\" -> pack subpath + | (toChar <$> [c5, c6, c7, c8]) == "UNC\\" -> + os "\\" <> pack subpath drive : col : subpath -- if the path is not "regular", then the prefix is necessary -- to ensure the path is interpreted literally diff --git a/changelog.md b/changelog.md index 67a13397..9a4cce2b 100644 --- a/changelog.md +++ b/changelog.md @@ -1,10 +1,12 @@ Changelog for the [`directory`][1] package ========================================== -## 1.3.8.3 (TBD) +## 1.3.8.3 (Jan 2024) * Relax `Win32` version bounds to support 2.14.0.0. ([#166](https://github.com/haskell/directory/issues/166)) + * Fix regression in `canonicalizePath` on Windows UNC paths. + ([#170](https://github.com/haskell/directory/issues/170)) ## 1.3.8.2 (Dec 2023) diff --git a/directory.cabal b/directory.cabal index eb81bb69..05008345 100644 --- a/directory.cabal +++ b/directory.cabal @@ -1,6 +1,6 @@ cabal-version: 2.2 name: directory -version: 1.3.8.2 +version: 1.3.8.3 license: BSD-3-Clause license-file: LICENSE maintainer: libraries@haskell.org diff --git a/tests/CanonicalizePath.hs b/tests/CanonicalizePath.hs index 03a3ba76..81e303c8 100644 --- a/tests/CanonicalizePath.hs +++ b/tests/CanonicalizePath.hs @@ -160,3 +160,14 @@ main _t = do vldn <- canonicalizePath "verylongdirectoryname" vldn2 <- canonicalizePath "VERYLONGDIRECTORYNAME" T(expectEq) () vldn vldn2 + + let isWindows = +#if defined(mingw32_HOST_OS) + True +#else + False +#endif + + when isWindows $ do + -- https://github.com/haskell/directory/issues/170 + T(expectEq) () "\\\\localhost" =<< canonicalizePath "\\\\localhost"