on master help sign in
Corrected cleanPathRel
e9e62f3Michael Snoyman
Network/Wai/Middleware/CleanPath.hs+5−2
@@ -7,9 +7,12 @@ import Network.URI (unEscapeString)
7-- | Performs redirects as per 'splitPath'.
7-- | Performs redirects as per 'splitPath'.
8cleanPathRel :: B.ByteString -> ([String] -> Request -> IO Response) -> Request -> IO Response
8cleanPathRel :: B.ByteString -> ([String] -> Request -> IO Response) -> Request -> IO Response
9cleanPathRel prefix app env =
9cleanPathRel prefix app env =
10− case splitPath (prefix `B.append` (pathInfo env)) of
10+ case splitPath $ pathInfo env of
11 Right pieces -> app pieces env
11 Right pieces -> app pieces env
12+ Left p -> return
12− Left p -> return . Response Status301 [(Location, B.append p suffix)] $ Right emptyEnum
13+ . Response Status301
14+ [(Location, B.concat [prefix, p, suffix])]
15+ $ Right emptyEnum
13 where
16 where
14 -- include the query string if present
17 -- include the query string if present
15 suffix =
18 suffix =