From 9bfe896eadfda1db6ecf4d25223f577b6eb6024b Mon Sep 17 00:00:00 2001 From: nixo Date: Fri, 30 Oct 2020 22:27:59 +0100 Subject: [PATCH] fix //url parsing --- src/types.jl | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/types.jl b/src/types.jl index d9559a8..709db12 100644 --- a/src/types.jl +++ b/src/types.jl @@ -49,13 +49,16 @@ struct Request spaces encoded with: %20" end +# TODO: https://tools.ietf.org/html/rfc3986#section-5.2.4 +# Read specs and fix implementation! function Request(data::String) reg = r""" - ((?P[^:/]+)://)? # optional protocol - (?P[^:/]+)? # required host (but can be omitted in parsing like /path/ or ./path) - (:(?P[0-9]{1,5}))? # optional port (will match impossible 65000+ ports) - (/(?P[^\?]*))? # optional path - (\?(?P.+))? # optional query + ((?P[^:/]+))? # optional protocol + ((:)?//)? # optional separator + (?P[^:/]+)? # required host (but can be omitted in parsing like /path/ or ./path) + (:(?P[0-9]{1,5}))? # optional port (will match impossible 65000+ ports) + (/(?P[^\?]*))? # optional path + (\?(?P.+))? # optional query """x s = endswith(data, "\r\n") ? data[1:end-2] : data m = match(reg, s)