Fix path.getrelative() when trailing slashes are present
This commit is contained in:
parent
b8bca5ddfc
commit
9831545e2d
@ -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';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -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
|
||||||
|
Loading…
Reference in New Issue
Block a user