attoparsec-uri 0.0.0 → 0.0.1
raw patch · 2 files changed
+9/−5 lines, 2 filesPVP: major bump suggested
API removals or changes: PVP suggests a major version bump
API changes (from Hackage documentation)
- Data.URI.Auth.Host: instance GHC.Generics.Selector Data.URI.Auth.Host.S1_2_0URIAuthHost
- Data.URI.Auth.Host: instance GHC.Generics.Selector Data.URI.Auth.Host.S1_2_1URIAuthHost
+ Data.URI.Auth.Host: Localhost :: URIAuthHost
+ Data.URI.Auth.Host: instance GHC.Generics.Constructor Data.URI.Auth.Host.C1_3URIAuthHost
+ Data.URI.Auth.Host: instance GHC.Generics.Selector Data.URI.Auth.Host.S1_3_0URIAuthHost
+ Data.URI.Auth.Host: instance GHC.Generics.Selector Data.URI.Auth.Host.S1_3_1URIAuthHost
Files
- attoparsec-uri.cabal +1/−1
- src/Data/URI/Auth/Host.hs +8/−4
attoparsec-uri.cabal view
@@ -1,5 +1,5 @@ name: attoparsec-uri-version: 0.0.0+version: 0.0.1 synopsis: URI parser / printer using attoparsec -- description: homepage: https://github.com/athanclark/attoparsec-uri#readme
src/Data/URI/Auth/Host.hs view
@@ -119,6 +119,7 @@ data URIAuthHost = IPv4 !IPv4 | IPv6 !IPv6+ | Localhost | -- | @Host ["foo","bar"] "com"@ represents @foo.bar.com@ Host { uriAuthHostName :: !(Vector Text)@@ -128,6 +129,7 @@ instance Show URIAuthHost where show (IPv4 l4) = showIPv4 l4 show (IPv6 r6) = showIPv6 r6+ show Localhost = "localhost" show (Host ns c) = intercalate "." $ V.toList $ T.unpack <$> ns `V.snoc` c @@ -135,13 +137,15 @@ parseURIAuthHost = (IPv4 <$> parseIPv4) <|> (IPv6 <$> parseIPv6)- <|> (uncurry Host <$> parseHost)+ <|> parseHost where- parseHost :: Parser (Vector Text, Text)+ parseHost :: Parser URIAuthHost parseHost = do xss@(x:xs) <- many1 (satisfy $ \c -> all (c /=) ['.',':','/','?']) `sepBy1` char '.' if null xs- then fail "Only one term parsed"+ then if x == "localhost"+ then pure Localhost+ else fail "Only one term parsed" else let xss' :: Vector Text xss' = T.pack <$> V.fromList xss unsnoc :: Vector a -> (Vector a, a)@@ -149,4 +153,4 @@ let (fs,l) = V.splitAt (V.length x - 1) x in (fs, l V.! 0) (ns,c) = unsnoc xss'- in pure (unsnoc xss')+ in pure (uncurry Host $ unsnoc xss')