aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorHisham Muhammad <hisham@gobolinux.org>2012-08-27 19:57:35 -0300
committerHisham Muhammad <hisham@gobolinux.org>2012-08-27 19:57:35 -0300
commited0524aa4f0d3875e9882ea745812bd27d3fb3be (patch)
treef9dd6ec339494e02e010e94aa76b341568dc8541 /src
parent90f5a852a6168661ece21f0918ea56d41c8b50ce (diff)
downloadluarocks-ed0524aa4f0d3875e9882ea745812bd27d3fb3be.tar.gz
luarocks-ed0524aa4f0d3875e9882ea745812bd27d3fb3be.tar.bz2
luarocks-ed0524aa4f0d3875e9882ea745812bd27d3fb3be.zip
Fix handling of "/" in dir.path. Closes #80.
Diffstat (limited to 'src')
-rw-r--r--src/luarocks/dir.lua11
1 files changed, 6 insertions, 5 deletions
diff --git a/src/luarocks/dir.lua b/src/luarocks/dir.lua
index 69968917..3de9e241 100644
--- a/src/luarocks/dir.lua
+++ b/src/luarocks/dir.lua
@@ -32,9 +32,10 @@ end
32 32
33--- Describe a path in a cross-platform way. 33--- Describe a path in a cross-platform way.
34-- Use this function to avoid platform-specific directory 34-- Use this function to avoid platform-specific directory
35-- separators in other modules. If the first item contains a 35-- separators in other modules. Removes trailing slashes from
36-- protocol descriptor (e.g. "http:"), paths are always constituted 36-- each component given, to avoid repeated separators.
37-- with forward slashes. 37-- Separators inside strings are kept, to handle URLs containing
38-- protocols.
38-- @param ... strings representing directories 39-- @param ... strings representing directories
39-- @return string: a string with a platform-specific representation 40-- @return string: a string with a platform-specific representation
40-- of the path. 41-- of the path.
@@ -42,14 +43,14 @@ function path(...)
42 local items = {...} 43 local items = {...}
43 local i = 1 44 local i = 1
44 while items[i] do 45 while items[i] do
45 items[i] = items[i]:gsub("/*$", "") 46 items[i] = items[i]:gsub("(.+)/+$", "%1")
46 if items[i] == "" then 47 if items[i] == "" then
47 table.remove(items, i) 48 table.remove(items, i)
48 else 49 else
49 i = i + 1 50 i = i + 1
50 end 51 end
51 end 52 end
52 return table.concat(items, "/") 53 return (table.concat(items, "/"):gsub("(.+)/+$", "%1"))
53end 54end
54 55
55--- Split protocol and path from an URL or local pathname. 56--- Split protocol and path from an URL or local pathname.