Fix path.getrelative() when trailing slashes are present

This commit is contained in:
Jason Perkins 2013-10-22 16:32:51 -04:00
parent b8bca5ddfc
commit 9831545e2d
2 changed files with 9 additions and 0 deletions

View File

@ -38,6 +38,11 @@ static void normalize(char* buffer, const char* path)
++src; ++src;
} }
/* remove any trailing slashes */
for (--src; src > buffer && *src == '/'; --src) {
*src = '\0';
}
*dst = '\0'; *dst = '\0';
} }

View File

@ -209,6 +209,10 @@
test.isequal("..", path.getrelative("/a///b/c","/a/b")) test.isequal("..", path.getrelative("/a///b/c","/a/b"))
end end
function suite.ignoresTrailingSlashes()
test.isequal("c", path.getrelative("/a/b/","/a/b/c"))
end
-- --
-- path.isabsolute() tests -- path.isabsolute() tests