Merge pull request #242 from Blizzard/fix-path-join

Recognize more situations where '..' should not be trimmed.
This commit is contained in:
starkos 2015-09-16 18:40:49 -04:00
commit 847fc633ac
2 changed files with 22 additions and 11 deletions

View File

@ -67,11 +67,11 @@ int path_join(lua_State* L)
}
/* if I hit a segment I can't trim, bail out */
if (*start == '$') {
break;
}
if (start[0] == '.' && start[1] == '.' && start[2] == '\0'){
if (strcmp(start, "..") == 0 /* parent dir */
|| strcmp(start, ".") == 0 /* current dir */
|| strstr(start, "**") != NULL /* recursive wildcard */
|| strchr(start, '$') != NULL) /* property expansion */
{
break;
}

View File

@ -209,13 +209,13 @@
test.isequal("..", path.getrelative("/a///b/c","/a/b"))
end
function suite.getrelative_ignoresTrailingSlashes()
test.isequal("c", path.getrelative("/a/b/","/a/b/c"))
end
function suite.getrelative_ignoresTrailingSlashes()
test.isequal("c", path.getrelative("/a/b/","/a/b/c"))
end
function suite.getrelative_returnsAbsPath_onContactWithFileSysRoot()
test.isequal("C:/Boost/Include", path.getrelative("C:/Code/MyApp", "C:/Boost/Include"))
end
function suite.getrelative_returnsAbsPath_onContactWithFileSysRoot()
test.isequal("C:/Boost/Include", path.getrelative("C:/Code/MyApp", "C:/Boost/Include"))
end
--
@ -323,6 +323,17 @@
test.isequal("$(ProjectDir)/$(TargetName)/../../Bin", path.join("$(ProjectDir)/$(TargetName)", "../../Bin"))
end
function suite.join_keepsComplexInternalEnvVar()
test.isequal("$(ProjectDir)/myobj_$(Arch)/../../Bin", path.join("$(ProjectDir)/myobj_$(Arch)", "../../Bin"))
end
function suite.join_keepsRecursivePattern()
test.isequal("p1/**.lproj/../p2", path.join("p1/**.lproj", "../p2"))
end
function suite.join_noCombineSingleDot()
test.isequal("p1/./../p2", path.join("p1/.", "../p2"))
end
--