diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/luarocks/core/dir.lua | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/src/luarocks/core/dir.lua b/src/luarocks/core/dir.lua index 59b7749c..d346ec4f 100644 --- a/src/luarocks/core/dir.lua +++ b/src/luarocks/core/dir.lua | |||
@@ -4,6 +4,15 @@ local dir = {} | |||
4 | local require = nil | 4 | local require = nil |
5 | -------------------------------------------------------------------------------- | 5 | -------------------------------------------------------------------------------- |
6 | 6 | ||
7 | local function unquote(c) | ||
8 | local first, last = c:sub(1,1), c:sub(-1) | ||
9 | if (first == '"' and last == '"') or | ||
10 | (first == "'" and last == "'") then | ||
11 | return c:sub(2,-2) | ||
12 | end | ||
13 | return c | ||
14 | end | ||
15 | |||
7 | --- Describe a path in a cross-platform way. | 16 | --- Describe a path in a cross-platform way. |
8 | -- Use this function to avoid platform-specific directory | 17 | -- Use this function to avoid platform-specific directory |
9 | -- separators in other modules. Removes trailing slashes from | 18 | -- separators in other modules. Removes trailing slashes from |
@@ -18,6 +27,9 @@ function dir.path(...) | |||
18 | while t[1] == "" do | 27 | while t[1] == "" do |
19 | table.remove(t, 1) | 28 | table.remove(t, 1) |
20 | end | 29 | end |
30 | for i, c in ipairs(t) do | ||
31 | t[i] = unquote(c) | ||
32 | end | ||
21 | return (table.concat(t, "/"):gsub("([^:])/+", "%1/"):gsub("^/+", "/"):gsub("/*$", "")) | 33 | return (table.concat(t, "/"):gsub("([^:])/+", "%1/"):gsub("^/+", "/"):gsub("/*$", "")) |
22 | end | 34 | end |
23 | 35 | ||
@@ -29,6 +41,7 @@ end | |||
29 | function dir.split_url(url) | 41 | function dir.split_url(url) |
30 | assert(type(url) == "string") | 42 | assert(type(url) == "string") |
31 | 43 | ||
44 | url = unquote(url) | ||
32 | local protocol, pathname = url:match("^([^:]*)://(.*)") | 45 | local protocol, pathname = url:match("^([^:]*)://(.*)") |
33 | if not protocol then | 46 | if not protocol then |
34 | protocol = "file" | 47 | protocol = "file" |