diff options
author | Thijs Schreijer <thijs@thijsschreijer.nl> | 2013-12-22 09:29:08 +0100 |
---|---|---|
committer | Thijs Schreijer <thijs@thijsschreijer.nl> | 2013-12-22 09:29:08 +0100 |
commit | c0563374ba47b554db92dfab949281c55210c3aa (patch) | |
tree | f31c4d1478377489e6696789857be919658612c8 | |
parent | df91dc76f867cc2c79bab1b086a5ed7e607b1d97 (diff) | |
download | luarocks-c0563374ba47b554db92dfab949281c55210c3aa.tar.gz luarocks-c0563374ba47b554db92dfab949281c55210c3aa.tar.bz2 luarocks-c0563374ba47b554db92dfab949281c55210c3aa.zip |
take urls into account besides local paths
-rw-r--r-- | src/luarocks/dir.lua | 10 |
1 files changed, 9 insertions, 1 deletions
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) | |||
64 | return protocol, pathname | 64 | return protocol, pathname |
65 | end | 65 | end |
66 | 66 | ||
67 | --- Normalize a url or local path. | ||
68 | -- URLs should be in the "protocol://path" format. System independent | ||
69 | -- forward slashes are used, removing trailing and double slashes | ||
70 | -- @param url string: an URL or a local pathname. | ||
71 | -- @return string: Normalized result. | ||
67 | function normalize(name) | 72 | function normalize(name) |
68 | return name:gsub("\\", "/"):gsub("(.)/*$", "%1"):gsub("//", "/") | 73 | local protocol, pathname = split_url(name) |
74 | pathname = pathname:gsub("\\", "/"):gsub("(.)/*$", "%1"):gsub("//", "/") | ||
75 | if protocol ~= "file" then pathname = protocol .."://"..pathname end | ||
76 | return pathname | ||
69 | end | 77 | end |