diff options
-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 |