on master help sign in
Fix bug in defaultMkRedirect
commitf5ce61c1fbfa7cc63691601fa24b57436dd9355a authorMichael Snoyman <michael@snoyman.com> dateFri 27 May 2011, 16:26 (15 years ago) parent7c33266
1 file changed+7−5
Network/Wai/Application/Static.hs+7−5
Network/Wai/Application/Static.hs+7−5
@@ -342,11 +342,13 @@ data StaticSettings = StaticSettings
342342 }
343343
344344defaultMkRedirect :: Pieces -> ByteString -> S8.ByteString
345−defaultMkRedirect pieces newPath =
346− let relDir = TE.encodeUtf8 (relativeDirFromPieces pieces) in
347− S8.append relDir (if (S8.last relDir) == '/' && (S8.head newPath) == '/'
348− then S8.tail newPath
349− else newPath)
345+defaultMkRedirect pieces newPath
346+ | S8.null newPath || S8.null relDir ||
347+ S8.last relDir /= '/' || S8.head newPath /= '/' =
348+ relDir `S8.append` newPath
349+ | otherwise = relDir `S8.append` S8.tail newPath
350+ where
351+ relDir = TE.encodeUtf8 (relativeDirFromPieces pieces)
350352
351353defaultStaticSettings :: CacheSettings -> StaticSettings
352354defaultStaticSettings isStaticFile = StaticSettings { ssFolder = fileSystemLookup "static"