urlpath 8.0.0 → 8.0.1
raw patch · 2 files changed
+18/−2 lines, 2 files
Files
- src/Data/Url.hs +17/−1
- urlpath.cabal +1/−1
src/Data/Url.hs view
@@ -3,6 +3,7 @@ , DeriveFunctor , KindSignatures , OverloadedStrings+ , OverloadedLists , FlexibleInstances , StandaloneDeriving , TypeSynonymInstances@@ -35,6 +36,7 @@ import Data.Functor.Identity import Data.Functor.Compose+import Data.Maybe (maybe) import Data.URI (URI (..)) import Data.URI.Auth (URIAuth (..)) import Data.URI.Auth.Host (URIAuthHost (Localhost))@@ -413,10 +415,24 @@ getPathChunks :: Path base type' -> V.Vector T.Text getPathChunks path = V.fromList $ fmap T.pack $ splitOn "/" $ dropWhile (== '/') (toFilePath path) ++ packLocation :: Strict.Maybe T.Text -> Bool -> URIAuth -> Location base type' -> URI packLocation scheme slashes auth loc = URI scheme slashes auth- (getPathChunks $ locPath loc)+ ( let unsnoc :: V.Vector a -> Maybe (V.Vector a, a)+ unsnoc vs+ | V.null vs = Nothing+ | otherwise =+ Just ( V.take (V.length vs - 1) vs+ , V.last vs+ )+ fileExt :: T.Text+ fileExt = maybe "" (("." <>) . T.pack) (locFileExt loc)+ in case unsnoc $ getPathChunks $ locPath loc of+ Nothing -> [fileExt]+ Just (xs,x) -> xs <> [x <> fileExt]+ ) ( V.fromList $ map (\(l,r) -> (T.pack l) Strict.:!:
urlpath.cabal view
@@ -1,5 +1,5 @@ Name: urlpath-Version: 8.0.0+Version: 8.0.1 Author: Athan Clark <athan.clark@gmail.com> Maintainer: Athan Clark <athan.clark@gmail.com> License: MIT