fix //url parsing
parent
1c8d815476
commit
9bfe896ead
13
src/types.jl
13
src/types.jl
|
@ -49,13 +49,16 @@ struct Request
|
||||||
spaces encoded with: %20"
|
spaces encoded with: %20"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# TODO: https://tools.ietf.org/html/rfc3986#section-5.2.4
|
||||||
|
# Read specs and fix implementation!
|
||||||
function Request(data::String)
|
function Request(data::String)
|
||||||
reg = r"""
|
reg = r"""
|
||||||
((?P<protocol>[^:/]+)://)? # optional protocol
|
((?P<protocol>[^:/]+))? # optional protocol
|
||||||
(?P<host>[^:/]+)? # required host (but can be omitted in parsing like /path/ or ./path)
|
((:)?//)? # optional separator
|
||||||
(:(?P<port>[0-9]{1,5}))? # optional port (will match impossible 65000+ ports)
|
(?P<host>[^:/]+)? # required host (but can be omitted in parsing like /path/ or ./path)
|
||||||
(/(?P<path>[^\?]*))? # optional path
|
(:(?P<port>[0-9]{1,5}))? # optional port (will match impossible 65000+ ports)
|
||||||
(\?(?P<query>.+))? # optional query
|
(/(?P<path>[^\?]*))? # optional path
|
||||||
|
(\?(?P<query>.+))? # optional query
|
||||||
"""x
|
"""x
|
||||||
s = endswith(data, "\r\n") ? data[1:end-2] : data
|
s = endswith(data, "\r\n") ? data[1:end-2] : data
|
||||||
m = match(reg, s)
|
m = match(reg, s)
|
||||||
|
|
Loading…
Reference in New Issue