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
13
13
import Global (readInt )
14
14
import qualified Data.String as S
15
15
import Text.Parsing.StringParser (Parser (), fail )
16
- import Text.Parsing.StringParser.Combinators (optionMaybe , sepBy1 )
16
+ import Text.Parsing.StringParser.Combinators (optionMaybe , sepBy )
17
17
import Text.Parsing.StringParser.String (string )
18
18
19
19
parseAuthority :: Parser Authority
20
20
parseAuthority = do
21
21
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)
24
26
return $ Authority ui (fromList hosts)
25
27
26
28
parsePort :: Parser Port
Original file line number Diff line number Diff line change @@ -14,10 +14,17 @@ import Text.Parsing.StringParser.Combinators (optionMaybe)
14
14
import Text.Parsing.StringParser.String (string )
15
15
16
16
parseHierarchicalPart :: 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 ))
21
28
22
29
printHierPart :: HierarchicalPart -> String
23
30
printHierPart (HierarchicalPart a p) =
Original file line number Diff line number Diff line change @@ -26,7 +26,16 @@ parseIPv4Address = IPv4Address <$> rxPat pattern <?> "IPv4 address"
26
26
octet = " (1[0-9]{2}|[1-9][0-9]|[0-9]|2[0-4][0-9]|25[0-5])"
27
27
28
28
parseRegName :: 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
+ )
30
39
31
40
printHost :: Host -> String
32
41
printHost (IPv6Address i) = " [" ++ i ++ " ]"
Original file line number Diff line number Diff line change @@ -12,6 +12,7 @@ import Text.Parsing.StringParser
12
12
13
13
14
14
main = do
15
+ test runParseURIRef " sql2:///?q=foo&var.bar=baz"
15
16
test runParseURIRef " mongodb://localhost"
16
17
test runParseURIRef " http://en.wikipedia.org/wiki/URI_scheme"
17
18
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