diff options
author | Hisham Muhammad <hisham@gobolinux.org> | 2013-12-22 05:01:48 -0800 |
---|---|---|
committer | Hisham Muhammad <hisham@gobolinux.org> | 2013-12-22 05:01:48 -0800 |
commit | 0bcdb08b4d99d5ba5841f0305b1230c16e198adb (patch) | |
tree | 2ad8152089f9da6918d84ada00626e35a7820899 | |
parent | ccc851f7f68047838241423530ce9ab349d51651 (diff) | |
parent | c0563374ba47b554db92dfab949281c55210c3aa (diff) | |
download | luarocks-0bcdb08b4d99d5ba5841f0305b1230c16e198adb.tar.gz luarocks-0bcdb08b4d99d5ba5841f0305b1230c16e198adb.tar.bz2 luarocks-0bcdb08b4d99d5ba5841f0305b1230c16e198adb.zip |
Merge pull request #207 from Tieske/normpath
Normalize search and list output paths on Windows
-rw-r--r-- | src/luarocks/dir.lua | 10 | ||||
-rw-r--r-- | src/luarocks/search.lua | 1 |
2 files changed, 10 insertions, 1 deletions
diff --git a/src/luarocks/dir.lua b/src/luarocks/dir.lua index 3c7465bb..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") | 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 |
diff --git a/src/luarocks/search.lua b/src/luarocks/search.lua index 356e06e8..76ea6815 100644 --- a/src/luarocks/search.lua +++ b/src/luarocks/search.lua | |||
@@ -305,6 +305,7 @@ function print_results(results, porcelain) | |||
305 | end | 305 | end |
306 | for version, repos in util.sortedpairs(versions, deps.compare_versions) do | 306 | for version, repos in util.sortedpairs(versions, deps.compare_versions) do |
307 | for _, repo in ipairs(repos) do | 307 | for _, repo in ipairs(repos) do |
308 | repo.repo = dir.normalize(repo.repo) | ||
308 | if porcelain then | 309 | if porcelain then |
309 | util.printout(package, version, repo.arch, repo.repo) | 310 | util.printout(package, version, repo.arch, repo.repo) |
310 | else | 311 | else |