microformats2-parser 1.0.1.1 → 1.0.1.2
raw patch · 3 files changed
+13/−4 lines, 3 filesPVP ok
version bump matches the API change (PVP)
API changes (from Hackage documentation)
Files
- library/Data/Microformats2/Parser.hs +7/−3
- microformats2-parser.cabal +1/−1
- test-suite/Data/Microformats2/ParserSpec.hs +5/−0
library/Data/Microformats2/Parser.hs view
@@ -24,6 +24,7 @@ import Data.Aeson.Types import Data.Aeson.Lens import Data.Char (isSpace)+import Data.List (isPrefixOf) import qualified Data.HashMap.Strict as HMS import qualified Data.Vector as V import Data.Maybe@@ -126,9 +127,12 @@ rootEl' = preprocessHtml rootEl resolveUrl ∷ Mf2ParserSettings → T.Text → T.Text-resolveUrl settings t = case parseURIReference $ T.unpack t of- Just u → T.pack $ uriToString id (u `relativeTo` fromMaybe nullURI (baseUri settings)) ""- Nothing → t+resolveUrl settings t =+ case parseURIReference $ resolveSlashSlash $ T.unpack t of+ Just u → T.pack $ uriToString id (u `relativeTo` baseUri') ""+ Nothing → t+ where resolveSlashSlash x = if "//" `isPrefixOf` x then uriScheme baseUri' ++ x else x+ baseUri' = fromMaybe nullURI (baseUri settings) preprocessHtml ∷ Element → Element preprocessHtml (Element n as ns) = Element (lowerName n) as $ map preprocessChildren $ filter (not . isTemplate) ns
microformats2-parser.cabal view
@@ -1,5 +1,5 @@ name: microformats2-parser-version: 1.0.1.1+version: 1.0.1.2 synopsis: A Microformats 2 parser. category: Web homepage: https://github.com/myfreeweb/microformats2-parser
test-suite/Data/Microformats2/ParserSpec.hs view
@@ -200,6 +200,11 @@ "rels": { "me": [ "http://com.example/atom.xml" ] }, "rel-urls": { "http://com.example/atom.xml": { "text": "feed", "rels": [ "me" ] } } }|] + parseMf2'' (def { baseUri = parseURI "http://com.example" }) [xml|<html> <a href="//example.com" rel=me>feed</a> </html>|] `shouldBe` [json|{+ "items": [],+ "rels": { "me": [ "http://example.com" ] },+ "rel-urls": { "http://example.com": { "text": "feed", "rels": [ "me" ] } } }|]+ parseMf2'' (def { baseUri = parseURI "http://com.example" }) [xml|<html> <base href="http://example.com"> <a href="/atom.xml" rel=me>feed</a> </html>|] `shouldBe` [json|{ "items": [], "rels": { "me": [ "http://example.com/atom.xml" ] },