Filepath Relative
Finds a relative path from a base path to a target path.
Inputs#
| Port | Description |
|---|---|
| The base path to measure from. | |
| The target path to measure to. |
Outputs#
| Port | Description |
|---|---|
| The resulting relative path. |
Addendum#
Calculates a relative path that navigates from basepath to targpath. The result is a path that, if appended to basepath, would point to the same location as targpath.
An error will occur if a relative path cannot be determined, for example, if the paths are on different drives on Windows.
Examples#
| Path Style | Base Path | Target Path | Result |
|---|---|---|---|
| POSIX | /a/b/c |
/a/b/c/d/e |
d/e |
| POSIX | /a/b/c |
/a/b/d/e |
../d/e |
| POSIX | /a/b |
/c/d |
../../c/d |
| Windows | C:\a\b\c |
C:\a\b\c\d\e |
d\e |
| Windows | C:\a\b\c |
C:\a\b\d\e |
..\d\e |
| Windows | C:\a\b |
D:\c\d |
(error) |
ID: core/filepath-rel@v1