From 8e39a526b57a2f9cf021f38cd9ffc8f88abd68fd Mon Sep 17 00:00:00 2001 From: Ryan Hartlage Date: Wed, 1 Aug 2018 15:52:02 -0400 Subject: Do not rewrite path in util.cleanup_path if the desired version is a substring of the version (#868) * Do not rewrite path in util.cleanup_path if the desired version is a substring of the version * Improve test coverage for core.util.cleanup_path --- src/luarocks/core/util.lua | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/luarocks/core/util.lua b/src/luarocks/core/util.lua index daec9d05..5f5c0fe1 100644 --- a/src/luarocks/core/util.lua +++ b/src/luarocks/core/util.lua @@ -166,7 +166,11 @@ function util.cleanup_path(list, sep, lua_version) for _, part in ipairs(parts) do part = part:gsub("//", "/") if lua_version then - part = part:gsub("/lua/[%d.]+/", "/lua/"..lua_version.."/") + part = part:gsub("/lua/([%d.]+)/", function(part_version) + if part_version:sub(1, #lua_version) ~= lua_version then + return "/lua/"..lua_version.."/" + end + end) end if not entries[part] then table.insert(final, part) -- cgit v1.2.3-55-g6feb