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