relativeToWeb

Computes the relative path to this path from base_path using web path rules.

The difference to relativeTo is that a path not ending in a slash will not be considered as a path to a directory and the parent path will instead be used.

@safe
relativeToWeb

Parameters

path Path

The destination path

base_path Path

The path from which the relative path starts

Examples

assert(Path("/some/path").relativeToWeb(Path("/")) == Path("some/path"));
assert(Path("/some/path/").relativeToWeb(Path("/some/other/path/")) == Path("../../path/"));
assert(Path("/some/path/").relativeToWeb(Path("/some/other/path")) == Path("../path/"));

See Also

relativeTo

Meta