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