on master help sign in
Use filepath to add trailing path separator
7e14eeaIlya Smelkov
servant-server/servant-server.cabal+2−1
@@ -53,10 +53,11 @@ library
53 , split >= 0.2 && < 0.3
53 , split >= 0.2 && < 0.3
54 , string-conversions >= 0.3 && < 0.4
54 , string-conversions >= 0.3 && < 0.4
55 , system-filepath >= 0.4 && < 0.5
55 , system-filepath >= 0.4 && < 0.5
56+ , filepath >= 1
56 , text >= 1.2 && < 1.3
57 , text >= 1.2 && < 1.3
57 , transformers >= 0.3 && < 0.5
58 , transformers >= 0.3 && < 0.5
58 , wai >= 3.0 && < 3.1
59 , wai >= 3.0 && < 3.1
59− , wai-app-static >= 3.0 && < 3.1
60+ , wai-app-static >= 3.0 && < 3.2
60 , warp >= 3.0 && < 3.1
61 , warp >= 3.0 && < 3.1
61 hs-source-dirs: src
62 hs-source-dirs: src
62 default-language: Haskell2010
63 default-language: Haskell2010
servant-server/src/Servant/Utils/StaticFiles.hs+3−4
@@ -7,7 +7,7 @@ module Servant.Utils.StaticFiles (
7 serveDirectory,
7 serveDirectory,
8 ) where
8 ) where
9
9
10−import Data.List (isSuffixOf)
10+import System.FilePath (addTrailingPathSeparator)
11import Network.Wai.Application.Static (staticApp, defaultFileServerSettings)
11import Network.Wai.Application.Static (staticApp, defaultFileServerSettings)
12import Servant.API.Raw (Raw)
12import Servant.API.Raw (Raw)
13import Servant.Server (Server)
13import Servant.Server (Server)
@@ -38,8 +38,7 @@ import Filesystem.Path.CurrentOS (decodeString)
38serveDirectory :: FilePath -> Server Raw
38serveDirectory :: FilePath -> Server Raw
39serveDirectory =
39serveDirectory =
40#if MIN_VERSION_wai_app_static(3,1,0)
40#if MIN_VERSION_wai_app_static(3,1,0)
41− staticApp . defaultFileServerSettings . mkSuff
41+ staticApp . defaultFileServerSettings . addTrailingPathSeparator
42#else
42#else
43− staticApp . defaultFileServerSettings . decodeString . mkSuff
43+ staticApp . defaultFileServerSettings . decodeString . addTrailingPathSeparator
44#endif
44#endif
45− where mkSuff x = if "/" `isSuffixOf` x then x else x ++ "/"