Classes

StaticRouteAbstractRoute

Utility for representing and manipulating a single static route in the router's configuration using string representation of the path expression with special param fields identified by :paramName prefix.

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.

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.

StaticRoute ⇐ AbstractRoute 

Utility for representing and manipulating a single static route in the router’s configuration using string representation of the path expression with special param fields identified by :paramName prefix.

Kind: global class
Extends: AbstractRoute


new StaticRoute(pathExpression) 

Param Type Description
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.

staticRoute._trimmedPathExpression : string 

The path expression with the trailing slashes trimmed.

Kind: instance property of StaticRoute


staticRoute._parameterNames : Array.<string> 

The names of the parameters in this route.

Kind: instance property of StaticRoute


staticRoute._hasParameters : boolean 

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

Kind: instance property of StaticRoute


staticRoute._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 StaticRoute


staticRoute.toPath() 

Kind: instance method of StaticRoute


staticRoute.matches() 

Kind: instance method of StaticRoute


staticRoute.extractParameters() 

Kind: instance method of StaticRoute


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

Replace required parameter placeholder in path with parameter value.

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

Param Type
path string
paramName string
paramValue string

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

Replace optional param placeholder in path with parameter value.

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

Param Type
path string
paramName string
paramValue string

staticRoute._cleanUnusedOptionalParams(path) ⇒ string 

Remove unused optional param placeholders in path.

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

Param Type
path string

staticRoute._isOptionalParamInPath(path, paramName) ⇒ boolean 

Returns true, if paramName is placed in path.

Kind: instance method of StaticRoute

Param Type
path string
paramName string

staticRoute._isRequiredParamInPath(path, paramName) ⇒ boolean 

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

Kind: instance method of StaticRoute

Param Type
path string
paramName string

staticRoute._getClearParamName(rawParam) ⇒ string 

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

Kind: instance method of StaticRoute

Param Type
rawParam string

staticRoute._getSubparamPattern(delimeter) ⇒ string 

Get pattern for subparameter.

Kind: instance method of StaticRoute

Param Type Description
delimeter string Parameters delimeter

staticRoute._checkOptionalParamsOrder(allMainParams) ⇒ boolean 

Check if all optional params are below required ones

Kind: instance method of StaticRoute

Param Type
allMainParams array.<string>

staticRoute._checkParametersOrder(clearedPathExpr) ⇒ Bool 

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

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

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

staticRoute._replaceOptionalParametersInPath(path, optionalParams) ⇒ string 

Convert main optional parameters to capture sequences

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

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

staticRoute._replaceRequiredSubParametersInPath(path, clearedPathExpr) ⇒ string 

Convert required subparameters to capture sequences

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

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

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

Convert optional subparameters to capture sequences

Kind: instance method of StaticRoute
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

staticRoute._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 StaticRoute
Returns: RegExp - The compiled regular expression.

Param Type Description
pathExpression string The path expression to compile.

staticRoute._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 StaticRoute
Returns: Object.<string, string> - The parsed path parameters.

Param Type Description
path string The URL path.

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

Extract parameters from given path.

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

Param Type
parameterValues Array.<string>

staticRoute._cleanOptParamName(paramName) ⇒ string 

Returns optional param name without “?”

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

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

staticRoute._isParamOptional(paramName) ⇒ boolean 

Checks if parameter is optional or not.

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

Param Type
paramName string

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

Extracts the parameter names from the provided path expression.

Kind: instance method of StaticRoute
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


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