url: fix parse (#14456)
parent
2835a190e8
commit
b8a0315574
|
@ -599,7 +599,7 @@ fn parse_host(host string) ?string {
|
||||||
return host1 + host2 + host3
|
return host1 + host2 + host3
|
||||||
}
|
}
|
||||||
if idx := host.last_index(':') {
|
if idx := host.last_index(':') {
|
||||||
colon_port = host[idx..]
|
colon_port = host[idx..i]
|
||||||
if !valid_optional_port(colon_port) {
|
if !valid_optional_port(colon_port) {
|
||||||
return error(error_msg('parse_host: invalid port $colon_port after host ',
|
return error(error_msg('parse_host: invalid port $colon_port after host ',
|
||||||
''))
|
''))
|
||||||
|
|
|
@ -98,3 +98,24 @@ fn test_parse_empty_query_two() ? {
|
||||||
assert qvalues_map == {}
|
assert qvalues_map == {}
|
||||||
assert query_str == query_encode
|
assert query_str == query_encode
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn test_parse() ? {
|
||||||
|
urls := [
|
||||||
|
'jdbc:mysql://test_user:ouupppssss@localhost:3306/sakila?profileSQL=true',
|
||||||
|
'ftp://ftp.is.co.za/rfc/rfc1808.txt',
|
||||||
|
'http://www.ietf.org/rfc/rfc2396.txt#header1',
|
||||||
|
'ldap://[2001:db8::7]/c=GB?objectClass=one&objectClass=two',
|
||||||
|
'mailto:John.Doe@example.com',
|
||||||
|
'news:comp.infosystems.www.servers.unix',
|
||||||
|
'tel:+1-816-555-1212',
|
||||||
|
'telnet://192.0.2.16:80/',
|
||||||
|
'urn:oasis:names:specification:docbook:dtd:xml:4.1.2',
|
||||||
|
'foo://example.com:8042/over/there?name=ferret#nose',
|
||||||
|
]
|
||||||
|
for url in urls {
|
||||||
|
_ := urllib.parse(url) or {
|
||||||
|
assert false
|
||||||
|
panic('FAILED parsing url')
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue