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.
- Source
Requires
Methods
(static) batchFixCustomWordCases(str, wordsopt) → {string}
Batch-customise word casings in a string. E.g. force fbi to FBI, ios to iOS, etc..
| Name | Type | Attributes | Description |
|---|---|---|---|
str | string | the string to apply the replacemnts to. | |
words | Array.<string> | <optional> | an array of words in their desired capitalisations. Defaults to the default list of custom capitalisations. |
- Source
- 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.
| Name | Type | Description |
|---|---|---|
str | string | the string to escape. |
- Source
- Type:
- string
(static) extractSlug(url, wordsopt) → {string}
Extract the slug from a URL and convert it to a title-case string.
| Name | Type | Attributes | Description |
|---|---|---|---|
url | string | ||
words | Array.<string> | <optional> | a list of words with custom capitalisations to correct after title-casing. |
- Source
- 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.
| Name | Type | Description |
|---|---|---|
text | string |
- Source
- Type:
- string
(static) stripQueryString(url) → {string}
Strip the query string from a URL.
| Name | Type | Description |
|---|---|---|
url | string |
- Source
- Type:
- string
(static) stripUTMParameters(url) → {string}
Remove UTM parameters from the query string in a URL.
| Name | Type | Description |
|---|---|---|
url | string |
- Source
- Type:
- string