fixed URL parsing in url.lua: parse fragment after parsing username and password.

This commit is contained in:
Herbert Leuwer 2017-11-19 19:48:37 +01:00
parent 5a17f79b03
commit 3ee89515a0

View File

@ -131,11 +131,6 @@ function _M.parse(url, default)
if not url or url == "" then return nil, "invalid url" end
-- remove whitespace
-- url = string.gsub(url, "%s", "")
-- get fragment
url = string.gsub(url, "#(.*)$", function(f)
parsed.fragment = f
return ""
end)
-- get scheme
url = string.gsub(url, "^([%w][%w%+%-%.]*)%:",
function(s) parsed.scheme = s; return "" end)
@ -149,6 +144,11 @@ function _M.parse(url, default)
parsed.query = q
return ""
end)
-- get fragment
url = string.gsub(url, "#(.*)$", function(f)
parsed.fragment = f
return ""
end)
-- get params
url = string.gsub(url, "%;(.*)", function(p)
parsed.params = p