matchPathPrefix()function
matchPathPrefix(target: PossiblePath, base: PossiblePath, caller: AnyCaller = matchPathPrefix): AbsolutePath | undefined
| Param | Type | |
|---|---|---|
target | PossiblePath | Path to match against base — relative paths resolve against base. required |
base | PossiblePath | Base path whose prefix is stripped from target. required |
caller | AnyCaller | Function to attribute a thrown error to (defaults to matchPathPrefix itself). Defaults to matchPathPrefix |
| Return | |
|---|---|
AbsolutePath | undefined | The remaining absolute path after stripping base, / for an exact match, or undefined if target is not under base. |
| Throws | |
|---|---|
RequiredError | If target or base is not a valid path. |
Examples
matchPathPrefix("/a/b", "/a") // "/b"