Skip to content

Commit

Permalink
Merge pull request #400 from Geod24/mlang/ConstPath
Browse files Browse the repository at this point in the history
Make relativeTo work with const paths
  • Loading branch information
s-ludwig authored Jun 18, 2024
2 parents 33eebc4 + 6de88fa commit c14b1dc
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion source/vibe/core/path.d
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import std.utf : byChar;
See_also: `relativeToWeb`
*/
Path relativeTo(Path)(Path path, Path base_path) @safe
Path relativeTo(Path)(in Path path, in Path base_path) @safe
if (isInstanceOf!(GenericPath, Path))
{
import std.array : array, replicate;
Expand Down Expand Up @@ -141,6 +141,13 @@ unittest {
assert(p1.relativeTo(p2).toString() == "");
assert(p2.relativeTo(p2).toString() == "./");
}

{
immutable PosixPath p1 = PosixPath("/foo/bar");
immutable PosixPath p2 = PosixPath("/foo");
immutable PosixPath result = p1.relativeTo(p2);
assert(result == PosixPath("bar"));
}
}

nothrow unittest {
Expand Down

0 comments on commit c14b1dc

Please sign in to comment.