on master help sign in
Fix bug in defaultMkRedirect
f5ce61cMichael Snoyman
Network/Wai/Application/Static.hs+7−5
@@ -342,11 +342,13 @@ data StaticSettings = StaticSettings
342 }
342 }
343
343
344defaultMkRedirect :: Pieces -> ByteString -> S8.ByteString
344defaultMkRedirect :: Pieces -> ByteString -> S8.ByteString
345−defaultMkRedirect pieces 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
346− let relDir = TE.encodeUtf8 (relativeDirFromPieces pieces) in
351+ relDir = TE.encodeUtf8 (relativeDirFromPieces pieces)
347− S8.append relDir (if (S8.last relDir) == '/' && (S8.head newPath) == '/'
348− then S8.tail newPath
349− else newPath)
350
352
351defaultStaticSettings :: CacheSettings -> StaticSettings
353defaultStaticSettings :: CacheSettings -> StaticSettings
352defaultStaticSettings isStaticFile = StaticSettings { ssFolder = fileSystemLookup "static"
354defaultStaticSettings isStaticFile = StaticSettings { ssFolder = fileSystemLookup "static"