mirror of
https://github.com/lunarmodules/luasocket.git
synced 2024-12-26 12:28:21 +01:00
fixed URL parsing in url.lua: parse fragment after parsing username and password.
This commit is contained in:
parent
5a17f79b03
commit
3ee89515a0
10
src/url.lua
10
src/url.lua
@ -131,11 +131,6 @@ function _M.parse(url, default)
|
|||||||
if not url or url == "" then return nil, "invalid url" end
|
if not url or url == "" then return nil, "invalid url" end
|
||||||
-- remove whitespace
|
-- remove whitespace
|
||||||
-- url = string.gsub(url, "%s", "")
|
-- url = string.gsub(url, "%s", "")
|
||||||
-- get fragment
|
|
||||||
url = string.gsub(url, "#(.*)$", function(f)
|
|
||||||
parsed.fragment = f
|
|
||||||
return ""
|
|
||||||
end)
|
|
||||||
-- get scheme
|
-- get scheme
|
||||||
url = string.gsub(url, "^([%w][%w%+%-%.]*)%:",
|
url = string.gsub(url, "^([%w][%w%+%-%.]*)%:",
|
||||||
function(s) parsed.scheme = s; return "" end)
|
function(s) parsed.scheme = s; return "" end)
|
||||||
@ -149,6 +144,11 @@ function _M.parse(url, default)
|
|||||||
parsed.query = q
|
parsed.query = q
|
||||||
return ""
|
return ""
|
||||||
end)
|
end)
|
||||||
|
-- get fragment
|
||||||
|
url = string.gsub(url, "#(.*)$", function(f)
|
||||||
|
parsed.fragment = f
|
||||||
|
return ""
|
||||||
|
end)
|
||||||
-- get params
|
-- get params
|
||||||
url = string.gsub(url, "%;(.*)", function(p)
|
url = string.gsub(url, "%;(.*)", function(p)
|
||||||
parsed.params = p
|
parsed.params = p
|
||||||
|
Loading…
Reference in New Issue
Block a user