Route

router/Route~ Route

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

Constructor

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

Source:
Initializes the route.
Parameters:
Name 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.

Members

_controller :string

Source:
The full name of Object Container alias identifying the controller associated with this route.
Type:
  • string

_hasParameters :boolean

Source:
Set to true if this route contains parameters in its path.
Type:
  • boolean

_matcher :RegExp

Source:
A regexp used to match URL path against this route and extract the parameter values from the matched URL paths.
Type:
  • RegExp

_name :string

Source:
The unique name of this route, identifying it among the rest of the routes in the application.
Type:
  • string

_options :Object

Source:
The route additional options.
Type:
  • Object

_parameterNames :Array.<string>

Source:
The names of the parameters in this route.
Type:
  • Array.<string>

_pathExpression :string

Source:
The original URL path expression from which this route was created.
Type:
  • string

_trimmedPathExpression :string

Source:
The path expression with the trailing slashes trimmed.
Type:
  • string

_view :React.Component

Source:
The full name or Object Container alias identifying the view class associated with this route.
Type:
  • React.Component

Methods

_cleanOptParamName(paramName) → {string}

Source:
Returns optional param name without "?"
Parameters:
Name Type Description
paramName string Full param name with "?"
Returns:
Strict param name without "?"
Type
string

_cleanUnusedOptionalParams(path) → {string}

Source:
Replace optional param placeholder in path with parameter value.
Parameters:
Name Type Description
path string
Returns:
New path.
Type
string

_compileToRegExp(pathExpression) → {RegExp}

Source:
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.
Parameters:
Name Type Description
pathExpression string The path expression to compile.
Returns:
The compiled regular expression.
Type
RegExp

_decodeURIParameter(parameterValue) → {string}

Source:
Decoding parameters.
Parameters:
Name Type Description
parameterValue string
Returns:
decodedValue
Type
string

_extractParameters(parameterValues) → {Object.<string, ?string>}

Source:
Extract parameters from given path.
Parameters:
Name Type Description
parameterValues Array.<string>
Returns:
Params object.
Type
Object.<string, ?string>

_getParameterNames(pathExpression) → {Array.<string>}

Source:
Extracts the parameter names from the provided path expression.
Parameters:
Name Type Description
pathExpression string The path expression.
Returns:
The names of the parameters defined in the provided path expression.
Type
Array.<string>

_getParameters(path) → {Object.<string, string>}

Source:
Parses the provided path and extract the in-path parameters. The method decodes the parameters and returns them in a hash object.
Parameters:
Name Type Description
path string The URL path.
Returns:
The parsed path parameters.
Type
Object.<string, string>

_getQuery(path) → {Object.<string, ?string>}

Source:
Extracts and decodes the query parameters from the provided URL path and query.
Parameters:
Name Type Description
path string The URL path, including the optional query string (if any).
Returns:
Parsed query parameters.
Type
Object.<string, ?string>

_getTrimmedPath(path) → {string}

Source:
Trims the trailing forward slash from the provided URL path.
Parameters:
Name Type Description
path string The path to trim.
Returns:
Trimmed path.
Type
string

_isParamInPath(path, paramName) → {boolean}

Source:
Returns true, if paramName is placed in path.
Parameters:
Name Type Description
path string
paramName string
Returns:
Type
boolean

_isParamOptional(paramName) → {boolean}

Source:
Checks if parameter is optional or not.
Parameters:
Name Type Description
paramName string
Returns:
return true if is optional, otherwise false
Type
boolean

_substituteOptionalParamInPath(path, paramName, paramValue) → {string}

Source:
Replace optional param placeholder in path with parameter value.
Parameters:
Name Type Description
path string
paramName string
paramValue string
Returns:
New path.
Type
string

_substituteParamInPath(path, paramName, paramValue) → {string}

Source:
Replace param placeholder in path with parameter value.
Parameters:
Name Type Description
path string
paramName string
paramValue string
Returns:
New path.
Type
string

extractParameters(path) → {Object.<string, ?string>}

Source:
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.
Parameters:
Name Type Description
path string
Returns:
Map of parameter names to parameter values.
Type
Object.<string, ?string>

getController() → {string}

Source:
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.
Returns:
The name of alias of the controller.
Type
string

getName() → {string}

Source:
Returns the unique identifying name of this route.
Returns:
The name of the route, identifying it.
Type
string

getOptions() → {Object}

Source:
Return route additional options.
Returns:
Type
Object

getPathExpression() → {string}

Source:
Returns the path expression, which is the parametrized pattern matching the URL paths matched by this route.
Returns:
The path expression.
Type
string

getView() → {string}

Source:
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.
Returns:
The name or alias of the view class.
Type
string

matches(path) → {boolean}

Source:
Tests whether the provided URL path matches this route. The provided path may contain the query.
Parameters:
Name Type Description
path string The URL path.
Returns:
true if the provided path matches this route.
Type
boolean

toPath(paramsopt) → {string}

Source:
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.
Parameters:
Name Type Attributes Default Description
params Object.<string, (number|string)> <optional>
{} The route parameter values.
Returns:
Path and, if necessary, query parts of the URL representing this route with its parameters replaced by the provided parameter values.
Type
string