isURLProud()function

isURLProud(target: PossibleURL | undefined, base: PossibleURL | undefined, caller: AnyCaller = isURLProud): boolean
ParamType
targetPossibleURL
URL whose status to test — relative paths resolve against base.
basePossibleURL
Base URL to test against.
callerAnyCaller
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 target is base or a descendant of base — i.e. base is at or above target in 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`