Skip to content

Commit fd6a5f3

Browse files
authored
Merge pull request #40 from garyb/numeric-hostname-parse-fix
Allow parsing of hostnames that start with numbers
2 parents 5600a0a + 2d48dc1 commit fd6a5f3

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

src/Data/URI/Host.purs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ derive instance genericHost ∷ Generic Host _
3636
instance showHostShow Host where show = genericShow
3737

3838
parser Parser Host
39-
parser = ipv6AddressParser <|> ipv4AddressParser <|> try regNameParser
39+
parser = try ipv6AddressParser <|> try ipv4AddressParser <|> regNameParser
4040

4141
-- TODO: this is much too forgiving right now
4242
ipv6AddressParser Parser Host

test/Main.purs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,16 @@ main = runTest $ suite "Data.URI" do
162162
Nothing)
163163
Nothing
164164
Nothing))
165+
testIsoURIRef
166+
"https://1a.example.com"
167+
(Left
168+
(URI
169+
(Just (Scheme "https"))
170+
(HierarchicalPart
171+
(Just (Authority Nothing [(Tuple (NameAddress "1a.example.com") Nothing)]))
172+
Nothing)
173+
Nothing
174+
Nothing))
165175
testIsoURIRef
166176
"http://en.wikipedia.org/wiki/URI_scheme"
167177
(Left

0 commit comments

Comments
 (0)