aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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.