src/parser.js
function mergeQuery(path, newQuery) {
    let parsed, properties, query, queryString;
    // Return the original path if the query to merge is empty.
    if (Object.keys(newQuery).length === 0) {
        return path;
    }
    // Parse the original path.
    parsed = url.parse(path, true);
    // Merge the queries to form a new query.
    query = parsed.query;
    properties = Object.keys(newQuery);
    for (let i = 0, u = properties.length; i < u; ++i) {
        let property = properties[i];
        query[property] = newQuery[property];
    }
    queryString = querystring.stringify(query);
    path = parsed.pathname + '?' + queryString;
    return path;
}
function mergeQuery(path, newQuery) {
    let parsed, properties, query, queryString;
    // Return the original path if the query to merge is empty.
    if (Object.keys(newQuery).length === 0) {
        return path;
    }
    // Parse the original path.
    parsed = url.parse(path, true);
    // Merge the queries to form a new query.
    query = parsed.query;
    properties = Object.keys(newQuery);
    for (let i = 0, u = properties.length; i < u; ++i) {
        let property = properties[i];
        query[property] = newQuery[property];
    }
    queryString = querystring.stringify(query);
    path = parsed.pathname + '?' + queryString;
    return path;
}
function mergeQuery ( path , newQuery ) { let parsed , properties , query , queryString ; // Return the original path if the query to merge is empty. if ( Object . keys ( newQuery ) . length === 0 ) { return path ; } // Parse the original path. parsed = url . parse ( path , true ) ; // Merge the queries to form a new query. query = parsed . query ; properties = Object . keys ( newQuery ) ; for ( let i = 0 , u = properties . length ; i < u ; ++ i ) { let property = properties [ i ] ; query [ property ] = newQuery [ property ] ; } queryString = querystring . stringify ( query ) ; path = parsed . pathname + '?' + queryString ; return path ; }
Merge additional query parameters onto an existing request path and return
the combined path + query

@param {string} path Request path, with or without a query
@param {Object} newQuery Query parameters to merge
@return {string} New path with query parameters merged
Merge additional query parameters onto an existing request path and return the combined path + query