on master help sign in
Expose toPiece
commit360dda46d893761cd555ada73eafa07d5bfd624d authorMichael Snoyman <michael@snoyman.com> dateFri 15 Jul 2011, 11:39 (15 years ago) parent8208384
1 file changed+10−9
Network/Wai/Application/Static.hs+10−9
Network/Wai/Application/Static.hs+10−9
@@ -30,6 +30,7 @@ module Network.Wai.Application.Static
3030 , Pieces
3131 , pathFromPieces
3232 , unfixPathName
33+ , toPiece
3334 -- ** Directory listings
3435 , Listing
3536 , defaultListing
@@ -489,11 +490,11 @@ toEmbedded fps =
489490 go texts
490491 where
491492 texts = map (\(x, y) -> (filter (not . T.null) $ toPieces x, y)) fps
492− toPiece fp = T.pack $ fixPathName fp
493+ toPiece' fp = T.pack $ fixPathName fp
493494 toPieces "" = []
494495 toPieces x =
495496 let (y, z) = break (== '/') x
496− in toPiece y : toPieces (drop 1 z)
497+ in toPiece' y : toPieces (drop 1 z)
497498 go :: [([T.Text], S8.ByteString)] -> Embedded
498499 go orig =
499500 Map.fromList $ map (second go') hoisted
@@ -523,13 +524,13 @@ runHashL :: L.ByteString -> ByteString
523524runHashL = B64.encode . MD5.hashlazy
524525
525526staticApp :: StaticSettings -> W.Application
526−staticApp set req =
527− staticAppPieces set (map toPiece $ W.pathInfo req) req
528− where
529− toPiece t = Piece
530− { piecePretty = t
531− , pieceRaw = unfixPathName $ T.unpack t
532− }
527+staticApp set req = staticAppPieces set (map toPiece $ W.pathInfo req) req
528+
529+toPiece :: T.Text -> Piece
530+toPiece t = Piece
531+ { piecePretty = t
532+ , pieceRaw = unfixPathName $ T.unpack t
533+ }
533534
534535status304, statusNotModified :: H.Status
535536status304 = H.Status 304 "Not Modified"