packages feed

http-directory 0.1.7 → 0.1.8

raw patch · 6 files changed

+42/−15 lines, 6 filesPVP ok

version bump matches the API change (PVP)

API changes (from Hackage documentation)

Files

CHANGELOG.md view
@@ -2,6 +2,11 @@  `http-directory` uses [PVP Versioning](https://pvp.haskell.org). +## 0.1.8 (2020-03-12)+- fix regression in 0.1.6 and 0.1.7: do not filter "*/" files+- more careful filter handling of '/'+- filter infix '#'+ ## 0.1.7 (2020-01-24) - drop </> since it conflicts with filepath - deprecates 0.1.6
LICENSE view
@@ -1,6 +1,6 @@ MIT License -Copyright (c) 2019 Jens Petersen+Copyright (c) 2019-2020 Jens Petersen  Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal
README.md view
@@ -12,7 +12,17 @@ html-conduit and xml-conduit to parse the html for links.  The library is intended for listing the files in http file directories,-but since http directories are just html pages it can actually be used+but since http directories are just html pages it can also be used to list the links (href's) on any html webpage. -See an [example](https://github.com/juhp/http-directory/blob/master/example/latest-ghc.hs) and the haddock documentation for usage.+## Usage Example++```haskell+Network.HTTP.Directory> :type httpDirectory'+httpDirectory' :: String -> IO [Text]+Network.HTTP.Directory> httpDirectory' "https://hackage.haskell.org/package/base/src/System"+["CPUTime.hsc","Environment.hs","Exit.hs","IO.hs","Info.hs","Mem.hs","Timeout.hs",+"CPUTime","Console","Environment","IO","Mem","Posix"]+```++See more [examples](https://github.com/juhp/http-directory/blob/master/example/) and the [latest haddock documentation](https://hackage.haskell.org/package/http-directory/docs/Network-HTTP-Directory.html) for more usage details.
http-directory.cabal view
@@ -1,6 +1,6 @@ cabal-version:       1.18 name:                http-directory-version:             0.1.7+version:             0.1.8 synopsis:            http directory listing library description:             Library for listing the files (href's) in an http directory.@@ -12,7 +12,7 @@ license-file:        LICENSE author:              Jens Petersen maintainer:          juhpetersen@gmail.com-copyright:           2019 Jens Petersen+copyright:           2019-2020 Jens Petersen category:            Network build-type:          Simple extra-doc-files:     README.md
src/Network/HTTP/Directory.hs view
@@ -81,20 +81,29 @@  defaultFilesFilter :: Maybe URI -> [Text] -> [Text] defaultFilesFilter mUri =-  L.nub . filter (not . or . flist (map T.isInfixOf [":", "?", "/"] ++ [(`elem` ["../", "..", "#"])])) . map removePath+  L.nub . filter (not . or . flist (map T.isInfixOf [":", "?", "#"] ++ [nonTrailingSlash] ++ [(`elem` ["../", ".."])])) . map removePath   where     -- picked from swish     flist :: [a->b] -> a -> [b]     flist fs a = map ($ a) fs +    -- may return "" which nonTrailingSlash then removes     removePath :: Text -> Text     removePath t =-      case mpath of+      case murlPath of         Nothing -> t         Just path ->-          fromMaybe t $ T.stripPrefix (T.pack path) t+          fromMaybe t $ T.stripPrefix path t -    mpath = uriPath <$> mUri+    murlPath :: Maybe Text+    murlPath = fmap (T.pack . trailingSlash . uriPath) mUri++    -- True means remove+    nonTrailingSlash :: Text -> Bool+    nonTrailingSlash "" = True     -- from removed uriPath+    nonTrailingSlash "/" = True+    nonTrailingSlash t =+      (T.length t > 1) && ("/" `T.isInfixOf` T.init t)  -- | Like httpDirectory but uses own Manager --
test/Spec.hs view
@@ -9,22 +9,25 @@ spec :: Spec spec = do   describe "httpDirectory" $ do-    it "empty google" $ do-      mgr <- httpManager-      fs <- httpDirectory mgr "https://google.com/"-      fs `shouldBe` []-     it "empty httpbin" $ do       mgr <- httpManager       fs <- httpDirectory mgr "http://httpbin.org/"       fs `shouldBe` [] +    it "fedora releases" $ do+      fs <- httpDirectory' "https://dl.fedoraproject.org/pub/fedora/linux/releases/"+      null fs `shouldBe` False+     it "my src hackage" $ do       fs <- httpDirectory' "https://hackage.haskell.org/package/http-directory/src/"       null fs `shouldBe` False -    it "myself hackage" $ do+    it "self hackage" $ do       fs <- httpDirectory' "https://hackage.haskell.org/package/http-directory"+      null fs `shouldBe` False++    it "self hackage" $ do+      fs <- httpDirectory' "https://mirrors.kernel.org/"       null fs `shouldBe` False      it "404" $