predictype / predicates/urls/urlHref / urlHref
urlHref(
source,oper,target):boolean
Defined in: predicates/urls/urlHref.ts:30
Checks the href component of a URL against a string operation.
URL
The URL to inspect.
The href operation to perform (e.g. ‘equals’, ‘includes’).
string
The string to compare against source.href.
boolean
True if the href comparison is valid according to the operator, otherwise false.
If the operation is not recognized.
const source = new URL('https://docs.example.com:443/path?q=1#intro');
const targetA = 'https://docs.example.com/path?q=1#intro';
const targetB = 'docs.example.com';
urlHref(source, 'equals', targetA); // true
urlHref(source, 'includes', targetB); // true
Supported Operators: