File tree Expand file tree Collapse file tree 4 files changed +27
-8
lines changed Expand file tree Collapse file tree 4 files changed +27
-8
lines changed Original file line number Diff line number Diff line change @@ -13,14 +13,16 @@ import Data.URI.UserInfo
1313import Global (readInt )
1414import qualified Data.String as S
1515import Text.Parsing.StringParser (Parser (), fail )
16- import Text.Parsing.StringParser.Combinators (optionMaybe , sepBy1 )
16+ import Text.Parsing.StringParser.Combinators (optionMaybe , sepBy )
1717import Text.Parsing.StringParser.String (string )
1818
1919parseAuthority :: Parser Authority
2020parseAuthority = do
2121 ui <- optionMaybe parseUserInfo
22- hosts <- flip sepBy1 (string " ," ) $ Tuple <$> parseHost
23- <*> optionMaybe (string " :" *> parsePort)
22+ hosts <- flip sepBy (string " ," )
23+ $ Tuple
24+ <$> parseHost
25+ <*> optionMaybe (string " :" *> parsePort)
2426 return $ Authority ui (fromList hosts)
2527
2628parsePort :: Parser Port
Original file line number Diff line number Diff line change @@ -14,10 +14,17 @@ import Text.Parsing.StringParser.Combinators (optionMaybe)
1414import Text.Parsing.StringParser.String (string )
1515
1616parseHierarchicalPart :: Parser HierarchicalPart
17- parseHierarchicalPart = (HierarchicalPart <$> optionMaybe (string " //" *> parseAuthority) <*> parsePathAbEmpty parseURIPathAbs)
18- <|> (HierarchicalPart Nothing <$> ((Just <$> parsePathAbsolute parseURIPathAbs)
19- <|> (Just <$> parsePathRootless parseURIPathAbs)
20- <|> pure Nothing ))
17+ parseHierarchicalPart =
18+ (HierarchicalPart
19+ <$> optionMaybe (string " //" *> parseAuthority)
20+ <*> parsePathAbEmpty parseURIPathAbs)
21+
22+ <|> (HierarchicalPart Nothing
23+ <$> ((Just <$> parsePathAbsolute parseURIPathAbs)
24+ <|>
25+ (Just <$> parsePathRootless parseURIPathAbs)
26+ <|>
27+ pure Nothing ))
2128
2229printHierPart :: HierarchicalPart -> String
2330printHierPart (HierarchicalPart a p) =
Original file line number Diff line number Diff line change @@ -26,7 +26,16 @@ parseIPv4Address = IPv4Address <$> rxPat pattern <?> "IPv4 address"
2626 octet = " (1[0-9]{2}|[1-9][0-9]|[0-9]|2[0-4][0-9]|25[0-5])"
2727
2828parseRegName :: Parser Host
29- parseRegName = NameAddress <$> try (joinWith " " <$> many1 (parseUnreserved <|> parsePCTEncoded <|> parseSubDelims))
29+ parseRegName =
30+ NameAddress
31+ <$> try
32+ (joinWith " "
33+ <$> many1 (parseUnreserved
34+ <|>
35+ parsePCTEncoded
36+ <|>
37+ parseSubDelims)
38+ )
3039
3140printHost :: Host -> String
3241printHost (IPv6Address i) = " [" ++ i ++ " ]"
Original file line number Diff line number Diff line change @@ -12,6 +12,7 @@ import Text.Parsing.StringParser
1212
1313
1414main = do
15+ test runParseURIRef " sql2:///?q=foo&var.bar=baz"
1516 test runParseURIRef " mongodb://localhost"
1617 test runParseURIRef " http://en.wikipedia.org/wiki/URI_scheme"
1718 test runParseURIRef " http://local.slamdata.com/?#?sort=asc&q=path%3A%2F&salt=1177214"
You can’t perform that action at this time.
0 commit comments