Fix replaceextension from adding a leading dot

When an empty string was passed to replaceextension
as the new extension, it added a leading dot,
this update fixes/prevents it.
This commit is contained in:
Eyal Solnik 2016-03-29 19:54:33 +03:00
parent 82fd64e00c
commit 9d068901f9
2 changed files with 5 additions and 1 deletions

View File

@ -231,7 +231,7 @@
return p
end
if not newext:findlast(".", true) then
if #newext > 0 and not newext:findlast(".", true) then
newext = "."..newext
end

View File

@ -420,6 +420,10 @@
function suite.getabsolute_replaceExtensionWithoutExtension()
test.isequal("/nunit/framework/main.foo", path.replaceextension("/nunit/framework/main",".foo"))
end
function suite.getabsolute_replaceExtensionWithEmptyString()
test.isequal("foo", path.replaceextension("foo.lua",""))
end