From c0563374ba47b554db92dfab949281c55210c3aa Mon Sep 17 00:00:00 2001 From: Thijs Schreijer Date: Sun, 22 Dec 2013 09:29:08 +0100 Subject: take urls into account besides local paths --- src/luarocks/dir.lua | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/luarocks/dir.lua b/src/luarocks/dir.lua index 5174fadc..e8cd746e 100644 --- a/src/luarocks/dir.lua +++ b/src/luarocks/dir.lua @@ -64,6 +64,14 @@ function split_url(url) return protocol, pathname end +--- Normalize a url or local path. +-- URLs should be in the "protocol://path" format. System independent +-- forward slashes are used, removing trailing and double slashes +-- @param url string: an URL or a local pathname. +-- @return string: Normalized result. function normalize(name) - return name:gsub("\\", "/"):gsub("(.)/*$", "%1"):gsub("//", "/") + local protocol, pathname = split_url(name) + pathname = pathname:gsub("\\", "/"):gsub("(.)/*$", "%1"):gsub("//", "/") + if protocol ~= "file" then pathname = protocol .."://"..pathname end + return pathname end -- cgit v1.2.3-55-g6feb