packages feed

hw-uri 0.1.1.5 → 0.1.1.6

raw patch · 2 files changed

+16/−1 lines, 2 filesPVP: minor bump suggested

API additions: PVP suggests at least a minor version bump

API changes (from Hackage documentation)

+ HaskellWorks.Data.Uri.Location: withoutPrefix :: Location -> Location -> Maybe Text

Files

hw-uri.cabal view
@@ -1,7 +1,7 @@ cabal-version:          2.4  name:                   hw-uri-version:                0.1.1.5+version:                0.1.1.6 synopsis:               Supports IO on URIs description:            Supports IO on URIs. homepage:               https://github.com/haskell-works/hw-uri
src/HaskellWorks/Data/Uri/Location.hs view
@@ -19,6 +19,7 @@   , modBasenameParts   , modBasenamePartsReversed   , modExts+  , withoutPrefix   ) where  import Antiope.Core              (ToText (..), fromText)@@ -163,3 +164,17 @@         f as = if L.isSuffixOf fromExts as           then (reverse (drop (length fromExts) (reverse as))) <> toExts           else as++withoutPrefix :: Location -> Location -> Maybe Text+withoutPrefix prefix location = case (prefix, location) of+  (S3 prefixUri, S3 locationUri) -> if prefixUri ^. the @"bucket" == locationUri ^. the @"bucket"+    then  let locationKey = locationUri ^. the @"objectKey" . the @1+              prefixKey   = prefixUri   ^. the @"objectKey" . the @1+          in if prefixKey `T.isPrefixOf` locationKey+            then Just (T.drop (T.length prefixKey) locationKey)+            else Nothing+    else Nothing+  (Local prefixUri, Local locationUri) -> if prefixUri `L.isPrefixOf` locationUri+    then Just (T.pack (drop (length prefixUri) locationUri))+    else Nothing+  _ -> Nothing