predictype / predicates/urls/urlHostname / urlHostname
urlHostname(
source,oper,target):boolean
Defined in: predicates/urls/urlHostname.ts:30
Checks the hostname component of a URL against a string operation.
URL
The URL to inspect.
The hostname operation to perform (e.g. ‘equals’, ‘excludes’).
string
The string to compare against source.hostname.
boolean
True if the hostname comparison is valid according to the operator, otherwise false.
If the operation is not recognized.
const source = new URL('https://blog.example.com/posts');
const targetA = 'blog.example.com';
const targetB = 'internal';
urlHostname(source, 'equals', targetA); // true
urlHostname(source, 'excludes', targetB); // true
Supported Operators: