Skip to main content

Class: UrlTransformer

@ima/core.UrlTransformer

Utility for transforming URLs according to the configured replacement rules.

Constructors

constructor

new UrlTransformer()

Initializes the URL transformer.

Defined in

packages/core/src/http/UrlTransformer.ts:16

Properties

_rules

Protected _rules: StringParameters

Defined in

packages/core/src/http/UrlTransformer.ts:7

Accessors

$dependencies

Static get $dependencies(): never[]

Returns

never[]

Defined in

packages/core/src/http/UrlTransformer.ts:9

Methods

addRule

addRule(pattern, replacement): UrlTransformer

Adds the provided replacement rule to the rules used by this URL transformer.

Parameters

NameTypeDescription
patternstringRegexp patter to look for (must be escaped as if for use in the Regexp constructor).
replacementstringThe replacement of the matched patter in any matched URL.

Returns

UrlTransformer

This transformer.

Defined in

packages/core/src/http/UrlTransformer.ts:30


clear

clear(): UrlTransformer

Clears all rules.

Returns

UrlTransformer

Defined in

packages/core/src/http/UrlTransformer.ts:39


transform

transform(url): string

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

NameTypeDescription
urlstringThe URL for transformation.

Returns

string

Transformed URL.

Defined in

packages/core/src/http/UrlTransformer.ts:53