X-Git-Url: http://git.cielonegro.org/gitweb.cgi?a=blobdiff_plain;ds=sidebyside;f=Network%2FHTTP%2FLucu%2FUtils.hs;h=1070d66f28042193a0337b02f1e9d858d63c9403;hb=b22e702f8161447a460847c6e6c97104c150534f;hp=8722ecb1a7264ebd450dff106aa283b0d423de0b;hpb=bb121f1189d01b5089aa5c29f0d390fad36ade48;p=Lucu.git diff --git a/Network/HTTP/Lucu/Utils.hs b/Network/HTTP/Lucu/Utils.hs index 8722ecb..1070d66 100644 --- a/Network/HTTP/Lucu/Utils.hs +++ b/Network/HTTP/Lucu/Utils.hs @@ -8,7 +8,7 @@ module Network.HTTP.Lucu.Utils ( splitBy , quoteStr , parseWWWFormURLEncoded - , splitPathInfo + , uriPathSegments , trim , (⊲) @@ -86,20 +86,20 @@ parseWWWFormURLEncoded src ) where unescape ∷ String → ByteString - unescape = Strict.pack ∘ unEscapeString ∘ map plusToSpace + unescape = Strict.pack ∘ unEscapeString ∘ (plusToSpace <$>) plusToSpace ∷ Char → Char plusToSpace '+' = ' ' plusToSpace c = c --- |>>> splitPathInfo "http://example.com/foo/bar" +-- |>>> uriPathSegments "http://example.com/foo/bar" -- ["foo", "bar"] -splitPathInfo ∷ URI → [ByteString] -splitPathInfo uri +uriPathSegments ∷ URI → [ByteString] +uriPathSegments uri = let reqPathStr = uriPath uri reqPath = [unEscapeString x | x ← splitBy (≡ '/') reqPathStr, (¬) (null x)] in - map Strict.pack reqPath + Strict.pack <$> reqPath -- |>>> trim " ab c d " -- "ab c d" @@ -142,6 +142,5 @@ getLastModified = (clockTimeToUTC <$>) ∘ getModificationTime where clockTimeToUTC ∷ ClockTime → UTCTime clockTimeToUTC (TOD sec picoSec) - = posixSecondsToUTCTime - $ fromRational + = posixSecondsToUTCTime ∘ fromRational $ sec % 1 + picoSec % (1000 ⋅ 1000 ⋅ 1000 ⋅ 1000)