UrlTransformer

http/UrlTransformer~ UrlTransformer

Utility for transforming URLs according to the configured replacement rules.

Constructor

new UrlTransformer()

Source:
Initializes the URL transformer.

Members

_rules :Object.<string, string>

Source:
Type:
  • Object.<string, string>

Methods

addRule(pattern, replacement) → {UrlTransformer}

Source:
Adds the provided replacement rule to the rules used by this URL transformer.
Parameters:
Name Type Description
pattern string Regexp patter to look for (must be escaped as if for use in the Regexp constructor).
replacement string The replacement of the matched patter in any matched URL.
Returns:
This transformer.
Type
UrlTransformer

clear() → {UrlTransformer}

Source:
Clears all rules.
Returns:
This transformer.
Type
UrlTransformer

transform(str) → {string}

Source:
Applies all rules registered with this URL transformer to the provided URL and returns the result. The rules will be applied in the order they were registered.
Parameters:
Name Type Description
str string The URL for transformation.
Returns:
Transformed URL.
Type
string