mirror of
https://github.com/lunarmodules/luasocket.git
synced 2024-12-26 04:28:20 +01:00
url.lua:absolute_path(): ensure a separator between base_path and relative_path
This commit is contained in:
parent
7ccea58776
commit
5b862e6a3c
@ -110,6 +110,7 @@ local function absolute_path(base_path, relative_path)
|
|||||||
if string.sub(relative_path, 1, 1) == "/" then
|
if string.sub(relative_path, 1, 1) == "/" then
|
||||||
return remove_dot_components(relative_path) end
|
return remove_dot_components(relative_path) end
|
||||||
base_path = base_path:gsub("[^/]*$", "")
|
base_path = base_path:gsub("[^/]*$", "")
|
||||||
|
if not base_path:find'/$' then base_path = base_path .. '/' end
|
||||||
local path = base_path .. relative_path
|
local path = base_path .. relative_path
|
||||||
path = remove_dot_components(path)
|
path = remove_dot_components(path)
|
||||||
return path
|
return path
|
||||||
|
@ -690,7 +690,7 @@ check_absolute_url("http://example.com/", "...badhost.com/", "http://example.com
|
|||||||
check_absolute_url("http://example.com/a/b/c/d/", "../q", "http://example.com/a/b/c/q")
|
check_absolute_url("http://example.com/a/b/c/d/", "../q", "http://example.com/a/b/c/q")
|
||||||
check_absolute_url("http://example.com/a/b/c/d/", "../../q", "http://example.com/a/b/q")
|
check_absolute_url("http://example.com/a/b/c/d/", "../../q", "http://example.com/a/b/q")
|
||||||
check_absolute_url("http://example.com/a/b/c/d/", "../../../q", "http://example.com/a/q")
|
check_absolute_url("http://example.com/a/b/c/d/", "../../../q", "http://example.com/a/q")
|
||||||
check_absolute_url("http://example.com/a/b/c/d/", "../../../../q", "http://example.com/q")
|
check_absolute_url("http://example.com", ".badhost.com", "http://example.com/.badhost.com")
|
||||||
|
|
||||||
print("testing path parsing and composition")
|
print("testing path parsing and composition")
|
||||||
check_parse_path("/eu/tu/ele", { "eu", "tu", "ele"; is_absolute = 1 })
|
check_parse_path("/eu/tu/ele", { "eu", "tu", "ele"; is_absolute = 1 })
|
||||||
|
Loading…
Reference in New Issue
Block a user