isURLProud()function
isURLProud(target: PossibleURL | undefined, base: PossibleURL | undefined, caller: AnyCaller = isURLProud): boolean
| Param | Type | |
|---|---|---|
target | PossibleURL | URL whose status to test — relative paths resolve against base. |
base | PossibleURL | Base URL to test against. |
caller | AnyCaller | Function to attribute a thrown error to — defaults to isURLProud. Defaults to isURLProud |
| Return | |
|---|---|
boolean | true if target is base or a descendant of base, otherwise false. |
Is a target URL proud relative to a base URL?
- Proud means
targetisbaseor a descendant ofbase— i.e.baseis at or abovetargetin the URL hierarchy. - Useful for marking a menu item as "current branch" when the user is somewhere deeper in its sub-tree.
- Origin mismatches return
false.
Examples
isURLProud("http://x.com/a/b", "http://x.com/a"); // `true`