Merge pull request #191 from Lusito/feature/pathjoinfix

fix for path.join problem when both string start with a "..", a unit …
This commit is contained in:
Manu Evans 2015-08-04 01:46:10 +10:00
commit 25bb49e4d5
2 changed files with 8 additions and 0 deletions

View File

@ -71,6 +71,10 @@ int path_join(lua_State* L)
break;
}
if (start[0] == '.' && start[1] == '.' && start[2] == '\0'){
break;
}
/* otherwise trim segment and the ".." sequence */
if (start != buffer) {
--start;

View File

@ -267,6 +267,10 @@
test.isequal("", path.join("p1/p2/", "../.."))
end
function suite.join_OnBothUpTwoFolders()
test.isequal("../../../../foo", path.join("../../", "../../foo"))
end
function suite.join_OnUptwoFolders()
test.isequal("p1/foo", path.join("p1/p2/p3", "../../foo"))
end