This module provides utility functions which are both used by the core code, and, available for use by users when defining link data transformers and link templates.

Requires

Methods

(static) batchFixCustomWordCases(str, wordsopt) → {string}

Batch-customise word casings in a string. E.g. force fbi to FBI, ios to iOS, etc..

Parameters:
NameTypeAttributesDescription
strstring

the string to apply the replacemnts to.

wordsArray.<string><optional>

an array of words in their desired capitalisations. Defaults to the default list of custom capitalisations.

Returns:
Type: 
string

(static) escapeRegex(str) → {string}

Escape a string for use in regular expressions.

Note: this is not a standard Javascript feature as of April 2026, though it is coming in future versions of Javascript.

Parameters:
NameTypeDescription
strstring

the string to escape.

Returns:
Type: 
string

(static) extractSlug(url, wordsopt) → {string}

Extract the slug from a URL and convert it to a title-case string.

Parameters:
NameTypeAttributesDescription
urlstring
wordsArray.<string><optional>

a list of words with custom capitalisations to correct after title-casing.

Returns:
Type: 
string

(static) regulariseWhitespace(text) → {string}

Regularise white space by replacing all sequences of whitespace characters with a single space and trimming leading and trailing whitespace.

Parameters:
NameTypeDescription
textstring
Returns:
Type: 
string

(static) stripQueryString(url) → {string}

Strip the query string from a URL.

Parameters:
NameTypeDescription
urlstring
Returns:
Type: 
string

(static) stripUTMParameters(url) → {string}

Remove UTM parameters from the query string in a URL.

Parameters:
NameTypeDescription
urlstring
Returns:
Type: 
string