lib/helpers/routeHelper.js
function extractQueryParameters (query) {
  return Object.keys(query.values)
    .reduce((queryParameters, name) => {
      // arrays in routing definitions are not supported
      if (util.isArray(query.values[name])) {
        return queryParameters;
      }

      // escape regular expression characters
      var escaped = query.values[name].replace(EXPRESSION_ESCAPE_REG_EXP, '\\$&');

      // get all occurrences of routing parameters in URI path
      var regExpSource = '^' + escaped.replace(PARAMETER_REG_EXP, URI_QUERY_REPLACEMENT_REG_EXP_SOURCE) + '$';
      var queryParameterMatches = escaped.match(PARAMETER_REG_EXP);

      if (!queryParameterMatches ||
          queryParameterMatches.length === 0) {
        return;
      }

      var parameter = getParameterDescriptor(queryParameterMatches[queryParameterMatches.length - 1]);
      var expression = new RegExp(regExpSource, 'i');
      parameter.map = createUriQueryValueMapper(expression);
      queryParameters[name] = parameter;
      return queryParameters;
    }, Object.create(null));
}
function extractQueryParameters (query) {
  return Object.keys(query.values)
    .reduce((queryParameters, name) => {
      // arrays in routing definitions are not supported
      if (util.isArray(query.values[name])) {
        return queryParameters;
      }

      // escape regular expression characters
      var escaped = query.values[name].replace(EXPRESSION_ESCAPE_REG_EXP, '\\$&');

      // get all occurrences of routing parameters in URI path
      var regExpSource = '^' + escaped.replace(PARAMETER_REG_EXP, URI_QUERY_REPLACEMENT_REG_EXP_SOURCE) + '$';
      var queryParameterMatches = escaped.match(PARAMETER_REG_EXP);

      if (!queryParameterMatches ||
          queryParameterMatches.length === 0) {
        return;
      }

      var parameter = getParameterDescriptor(queryParameterMatches[queryParameterMatches.length - 1]);
      var expression = new RegExp(regExpSource, 'i');
      parameter.map = createUriQueryValueMapper(expression);
      queryParameters[name] = parameter;
      return queryParameters;
    }, Object.create(null));
}
function extractQueryParameters ( query ) { return Object . keys ( query . values ) . reduce ( ( queryParameters , name ) => { // arrays in routing definitions are not supported if ( util . isArray ( query . values [ name ] ) ) { return queryParameters ; } // escape regular expression characters var escaped = query . values [ name ] . replace ( EXPRESSION_ESCAPE_REG_EXP , '\\$&' ) ; // get all occurrences of routing parameters in URI path var regExpSource = '^' + escaped . replace ( PARAMETER_REG_EXP , URI_QUERY_REPLACEMENT_REG_EXP_SOURCE ) + '$' ; var queryParameterMatches = escaped . match ( PARAMETER_REG_EXP ) ; if ( ! queryParameterMatches || queryParameterMatches . length === 0 ) { return ; } var parameter = getParameterDescriptor ( queryParameterMatches [ queryParameterMatches . length - 1 ] ) ; var expression = new RegExp ( regExpSource , 'i' ) ; parameter . map = createUriQueryValueMapper ( expression ) ; queryParameters [ name ] = parameter ; return queryParameters ; } , Object . create ( null ) ) ; }
Extracts query parameters to a key-value object
@param {String} query
@returns {Object} key-value query parameter map
Extracts query parameters to a key - value object