Classes: PathAliasManager

PathAliasManager

Utility that manages loading and resolving simple path aliases (mappings from one path to another path).


new PathAliasManager()

Source:

Methods


addConfig(getAliases, scope)

Add aliases to the configuration

Parameters:
Name Type Default Description
getAliases function

A callback that retrieves the aliases configuration. This function will only be called once the user navigates to a path that falls within the scope of this configuration. The function will receive the parameters that the page renderer passes to the injectParams parameter of the handleRequest method. This function should return an object or a Promise that resolves with an object of the following shape:

[
   { from: 'from path', to: 'to path' },
   { from: 'from path', to: 'to path' },
   ...
]
scope string /

The paths that are included in this config. Once the user navigates to a path that starts with this string, the getAliases callback will be called to load the aliases configuration.

Source:

<async> handleRequest(path, injectParams)

Resolves aliases for the given path. Will load in any configuration added with addConfig, if they had not been loaded already.

Parameters:
Name Type Description
path string

The requested path

injectParams Object

The parameters that will be injected to the getAliases callback of the configs. These should contain the redux store dispatch and getState.

Source:
Returns:

A promise that resolves with the path that should be redirected to, or false if no matching aliases have been found.

Type
Promise.<(boolean|string)>