predictype

predictype v0.13.0


predictype / predicates/urls/urlHash / urlHash

Function: urlHash()

urlHash(source, oper, target): boolean

Defined in: predicates/urls/urlHash.ts:30

Checks the hash component of a URL against a string operation.

Parameters

source

URL

The URL to inspect.

oper

UrlHashOper

The hash operation to perform (e.g. ‘equals’, ‘starts_with’).

target

string

The string to compare against source.hash.

Returns

boolean

True if the hash comparison is valid according to the operator, otherwise false.

Throws

If the operation is not recognized.

Example

const source = new URL('https://example.com/docs#install');
const targetA = '#install';
const targetB = '#guide';

urlHash(source, 'equals', targetA); // true
urlHash(source, 'not_equals', targetB); // true

Remarks

Supported Operators: