Classes

Route

Utility for representing and manipulating a single route in the router's configuration.

Constants

CONTROL_CHARACTERS_REGEXP : RegExp

Regular expression matching all control characters used in regular expressions. The regular expression is used to match these characters in path expressions and replace them appropriately so the path expression can be compiled to a regular expression.

LOOSE_SLASHES_REGEXP : RegExp

Regular expression used to match and remove the starting and trailing forward slashes from a path expression or a URL path.

PARAMS_REGEXP_UNIVERSAL : RegExp

Regular expression used to match the parameter names from a path expression.

PARAMS_REGEXP_REQUIRED : RegExp

Regular expression used to match the required parameter names from a path expression.

PARAMS_REGEXP_CORE_NAME : RegExp

Regular expression used to separate a camelCase parameter name

PARAMS_START_PATTERN : String

Regular expression used to match start of parameter names from a path expression.

PARAMS_END_PATTERN : String

Regular expression used to match end of parameter names from a path expression.

PARAMS_NEVER_MATCH_REGEXP : RegExp

Regular expression used to never match the parameter names from a path expression. It's used for wrong parameters order (optional vs. required ones)

PARAMS_MAIN_REGEXP : RegExp

Regular expression used to match all main parameter names from a path expression.

SUBPARAMS_REQUIRED_REGEXP : Object.<String, RegExp>

Regular expression used to match the required subparameter names from a path expression. (e.g. for path '/:paramA-:paramB/:nextParam' are subparametres 'paramA' and 'paramB')

SUBPARAMS_OPT_REGEXP : Object.<String, RegExp>

Regular expression used to match the optional parameter names from a path expression.

PARAMS_REGEXP_OPT : RegExp

Regular expression used to match the parameter names from a path expression.

Route 

Utility for representing and manipulating a single route in the router’s configuration.

Kind: global class


new Route(name, pathExpression, controller, view, options) 

Initializes the route.

Param Type Description
name string The unique name of this route, identifying it among the rest of the routes in the application.
pathExpression string A path expression specifying the URL path part matching this route (must not contain a query string), optionally containing named parameter placeholders specified as :parameterName.
controller string The full name of Object Container alias identifying the controller associated with this route.
view string The full name or Object Container alias identifying the view class associated with this route.
options Object The route additional options.

route._name : string 

The unique name of this route, identifying it among the rest of the routes in the application.

Kind: instance property of Route


route._pathExpression : string 

The original URL path expression from which this route was created.

Kind: instance property of Route


route._controller : string 

The full name of Object Container alias identifying the controller associated with this route.

Kind: instance property of Route


route._view : React.Component 

The full name or Object Container alias identifying the view class associated with this route.

Kind: instance property of Route


route._options : Object 

The route additional options.

Kind: instance property of Route


route._trimmedPathExpression : string 

The path expression with the trailing slashes trimmed.

Kind: instance property of Route


route._parameterNames : Array.<string> 

The names of the parameters in this route.

Kind: instance property of Route


route._hasParameters : boolean 

Set to true if this route contains parameters in its path.

Kind: instance property of Route


route._matcher : RegExp 

A regexp used to match URL path against this route and extract the parameter values from the matched URL paths.

Kind: instance property of Route


route.toPath([params]) ⇒ string 

Creates the URL and query parts of a URL by substituting the route’s parameter placeholders by the provided parameter value.

The extraneous parameters that do not match any of the route’s placeholders will be appended as the query string.

Kind: instance method of Route
Returns: string - Path and, if necessary, query parts of the URL representing this route with its parameters replaced by the provided parameter values.

Param Type Default Description
[params] Object.<string, (number\|string)> {} The route parameter values.

route.getName() ⇒ string 

Returns the unique identifying name of this route.

Kind: instance method of Route
Returns: string - The name of the route, identifying it.


route.getController() ⇒ string 

Returns the full name of the controller to use when this route is matched by the current URL, or an Object Container-registered alias of the controller.

Kind: instance method of Route
Returns: string - The name of alias of the controller.


route.getView() ⇒ string 

Returns the full name of the view class or an Object Container-registered alias for the view class, representing the view to use when this route is matched by the current URL.

Kind: instance method of Route
Returns: string - The name or alias of the view class.


route.getOptions() ⇒ Object 

Return route additional options.

Kind: instance method of Route


route.getPathExpression() ⇒ string 

Returns the path expression, which is the parametrized pattern matching the URL paths matched by this route.

Kind: instance method of Route
Returns: string - The path expression.


route.matches(path) ⇒ boolean 

Tests whether the provided URL path matches this route. The provided path may contain the query.

Kind: instance method of Route
Returns: boolean - true if the provided path matches this route.

Param Type Description
path string The URL path.

route.extractParameters(path) ⇒ Object.<string, ?string> 

Extracts the parameter values from the provided path. The method extracts both the in-path parameters and parses the query, allowing the query parameters to override the in-path parameters.

The method returns an empty hash object if the path does not match this route.

Kind: instance method of Route
Returns: Object.<string, ?string> - Map of parameter names to parameter values.

Param Type
path string

route._substituteRequiredParamInPath(path, paramName, paramValue) ⇒ string 

Replace required parameter placeholder in path with parameter value.

Kind: instance method of Route
Returns: string - New path.

Param Type
path string
paramName string
paramValue string

route._substituteOptionalParamInPath(path, paramName, paramValue) ⇒ string 

Replace optional param placeholder in path with parameter value.

Kind: instance method of Route
Returns: string - New path.

Param Type
path string
paramName string
paramValue string

route._cleanUnusedOptionalParams(path) ⇒ string 

Remove unused optional param placeholders in path.

Kind: instance method of Route
Returns: string - New path.

Param Type
path string

route._isOptionalParamInPath(path, paramName) ⇒ boolean 

Returns true, if paramName is placed in path.

Kind: instance method of Route

Param Type
path string
paramName string

route._isRequiredParamInPath(path, paramName) ⇒ boolean 

Returns true, if paramName is placed in path and it’s required.

Kind: instance method of Route

Param Type
path string
paramName string

route._getClearParamName(rawParam) ⇒ string 

Extract clear parameter name, e.q. ‘?name’ or ‘name’

Kind: instance method of Route

Param Type
rawParam string

route._getSubparamPattern(delimeter) ⇒ string 

Get pattern for subparameter.

Kind: instance method of Route

Param Type Description
delimeter string Parameters delimeter

route._checkOptionalParamsOrder(allMainParams) ⇒ boolean 

Check if all optional params are below required ones

Kind: instance method of Route

Param Type
allMainParams array.<string>

route._checkParametersOrder(clearedPathExpr) ⇒ Bool 

Check if main parametres have correct order. It means that required param cannot follow optional one.

Kind: instance method of Route
Returns: Bool - Returns TRUE if order is correct.

Param Type Description
clearedPathExpr string The cleared URL path (removed first and last slash, …).

route._replaceOptionalParametersInPath(path, optionalParams) ⇒ string 

Convert main optional parameters to capture sequences

Kind: instance method of Route
Returns: string - RegExp pattern.

Param Type Description
path string The URL path.
optionalParams array.<string> List of main optimal parameter expressions

route._replaceRequiredSubParametersInPath(path, clearedPathExpr) ⇒ string 

Convert required subparameters to capture sequences

Kind: instance method of Route
Returns: string - RegExp pattern.

Param Type Description
path string The URL path (route definition).
clearedPathExpr string The original cleared URL path.

route._replaceOptionalSubParametersInPath(path, optionalSubparamsOthers, optionalSubparamsLast) ⇒ string 

Convert optional subparameters to capture sequences

Kind: instance method of Route
Returns: string - RegExp pattern.

Param Type Description
path string The URL path (route definition).
optionalSubparamsOthers array.<string> List of all subparam. expressions but last ones
optionalSubparamsLast array.<string> List of last subparam. expressions

route._compileToRegExp(pathExpression) ⇒ RegExp 

Compiles the path expression to a regular expression that can be used for easier matching of URL paths against this route, and extracting the path parameter values from the URL path.

Kind: instance method of Route
Returns: RegExp - The compiled regular expression.

Param Type Description
pathExpression string The path expression to compile.

route._getParameters(path) ⇒ Object.<string, string> 

Parses the provided path and extract the in-path parameters. The method decodes the parameters and returns them in a hash object.

Kind: instance method of Route
Returns: Object.<string, string> - The parsed path parameters.

Param Type Description
path string The URL path.

route._extractParameters(parameterValues) ⇒ Object.<string, ?string> 

Extract parameters from given path.

Kind: instance method of Route
Returns: Object.<string, ?string> - Params object.

Param Type
parameterValues Array.<string>

route._decodeURIParameter(parameterValue) ⇒ string 

Decoding parameters.

Kind: instance method of Route
Returns: string - decodedValue

Param Type
parameterValue string

route._cleanOptParamName(paramName) ⇒ string 

Returns optional param name without “?”

Kind: instance method of Route
Returns: string - Strict param name without “?”

Param Type Description
paramName string Full param name with “?”

route._isParamOptional(paramName) ⇒ boolean 

Checks if parameter is optional or not.

Kind: instance method of Route
Returns: boolean - return true if is optional, otherwise false

Param Type
paramName string

route._getQuery(path) ⇒ Object.<string, ?string> 

Extracts and decodes the query parameters from the provided URL path and query.

Kind: instance method of Route
Returns: Object.<string, ?string> - Parsed query parameters.

Param Type Description
path string The URL path, including the optional query string (if any).

route._getTrimmedPath(path) ⇒ string 

Trims the trailing forward slash from the provided URL path.

Kind: instance method of Route
Returns: string - Trimmed path.

Param Type Description
path string The path to trim.

route._getParameterNames(pathExpression) ⇒ Array.<string> 

Extracts the parameter names from the provided path expression.

Kind: instance method of Route
Returns: Array.<string> - The names of the parameters defined in the provided path expression.

Param Type Description
pathExpression string The path expression.

CONTROL_CHARACTERS_REGEXP : RegExp 

Regular expression matching all control characters used in regular expressions. The regular expression is used to match these characters in path expressions and replace them appropriately so the path expression can be compiled to a regular expression.

Kind: global constant


LOOSE_SLASHES_REGEXP : RegExp 

Regular expression used to match and remove the starting and trailing forward slashes from a path expression or a URL path.

Kind: global constant


PARAMS_REGEXP_UNIVERSAL : RegExp 

Regular expression used to match the parameter names from a path expression.

Kind: global constant


PARAMS_REGEXP_REQUIRED : RegExp 

Regular expression used to match the required parameter names from a path expression.

Kind: global constant


PARAMS_REGEXP_CORE_NAME : RegExp 

Regular expression used to separate a camelCase parameter name

Kind: global constant


PARAMS_START_PATTERN : String 

Regular expression used to match start of parameter names from a path expression.

Kind: global constant


PARAMS_END_PATTERN : String 

Regular expression used to match end of parameter names from a path expression.

Kind: global constant


PARAMS_NEVER_MATCH_REGEXP : RegExp 

Regular expression used to never match the parameter names from a path expression. It’s used for wrong parameters order (optional vs. required ones)

Kind: global constant


PARAMS_MAIN_REGEXP : RegExp 

Regular expression used to match all main parameter names from a path expression.

Kind: global constant


SUBPARAMS_REQUIRED_REGEXP : Object.<String, RegExp> 

Regular expression used to match the required subparameter names from a path expression. (e.g. for path ‘/:paramA-:paramB/:nextParam’ are subparametres ‘paramA’ and ‘paramB’)

Kind: global constant


SUBPARAMS_OPT_REGEXP : Object.<String, RegExp> 

Regular expression used to match the optional parameter names from a path expression.

Kind: global constant


PARAMS_REGEXP_OPT : RegExp 

Regular expression used to match the parameter names from a path expression.

Kind: global constant