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