lib/helpers/routeHelper.js
function createUriPathMapper (expression, parameters) {
  return (uriPath, args) => {
    var matches = uriPath.match(expression);
    if (!matches || matches.length < 2) {
      return args;
    }

    // start with second match because first match is always
    // the whole URI path
    matches = matches.splice(1);

    parameters.forEach((parameter, index) => {
      var value = matches[index];

      try {
        value = decodeURIComponent(value);
      } catch (e) {
        // nothing to do
      }

      args[parameter.name] = value;
    });
  };
}
function createUriPathMapper (expression, parameters) {
  return (uriPath, args) => {
    var matches = uriPath.match(expression);
    if (!matches || matches.length < 2) {
      return args;
    }

    // start with second match because first match is always
    // the whole URI path
    matches = matches.splice(1);

    parameters.forEach((parameter, index) => {
      var value = matches[index];

      try {
        value = decodeURIComponent(value);
      } catch (e) {
        // nothing to do
      }

      args[parameter.name] = value;
    });
  };
}
function createUriPathMapper ( expression , parameters ) { return ( uriPath , args ) => { var matches = uriPath . match ( expression ) ; if ( ! matches || matches . length < 2 ) { return args ; } // start with second match because first match is always // the whole URI path matches = matches . splice ( 1 ) ; parameters . forEach ( ( parameter , index ) => { var value = matches [ index ] ; try { value = decodeURIComponent ( value ) ; } catch ( e ) { // nothing to do } args [ parameter . name ] = value ; } ) ; } ; }
Creates new URI path-to-state object mapper.
@param {RegExp} expression Regular expression to match URI path.
@param {Array} parameters List of parameter descriptors.
@returns {Function} URI mapper function.
Creates new URI path - to - state object mapper .