index.js
function querystringify(obj, prefix) {
  prefix = prefix || '';

  var pairs = []
    , value
    , key;

  //
  // Optionally prefix with a '?' if needed
  //
  if ('string' !== typeof prefix) prefix = '?';

  for (key in obj) {
    if (has.call(obj, key)) {
      value = obj[key];

      //
      // Edge cases where we actually want to encode the value to an empty
      // string instead of the stringified value.
      //
      if (!value && (value === null || value === undef || isNaN(value))) {
        value = '';
      }

      key = encodeURIComponent(key);
      value = encodeURIComponent(value);

      //
      // If we failed to encode the strings, we should bail out as we don't
      // want to add invalid strings to the query.
      //
      if (key === null || value === null) continue;
      pairs.push(key +'='+ value);
    }
  }

  return pairs.length ? prefix + pairs.join('&') : '';
}
function querystringify(obj, prefix) {
  prefix = prefix || '';

  var pairs = []
    , value
    , key;

  //
  // Optionally prefix with a '?' if needed
  //
  if ('string' !== typeof prefix) prefix = '?';

  for (key in obj) {
    if (has.call(obj, key)) {
      value = obj[key];

      //
      // Edge cases where we actually want to encode the value to an empty
      // string instead of the stringified value.
      //
      if (!value && (value === null || value === undef || isNaN(value))) {
        value = '';
      }

      key = encodeURIComponent(key);
      value = encodeURIComponent(value);

      //
      // If we failed to encode the strings, we should bail out as we don't
      // want to add invalid strings to the query.
      //
      if (key === null || value === null) continue;
      pairs.push(key +'='+ value);
    }
  }

  return pairs.length ? prefix + pairs.join('&') : '';
}
function querystringify ( obj , prefix ) { prefix = prefix || '' ; var pairs = [ ] , value , key ; // // Optionally prefix with a '?' if needed // if ( 'string' !== typeof prefix ) prefix = '?' ; for ( key in obj ) { if ( has . call ( obj , key ) ) { value = obj [ key ] ; // // Edge cases where we actually want to encode the value to an empty // string instead of the stringified value. // if ( ! value && ( value === null || value === undef || isNaN ( value ) ) ) { value = '' ; } key = encodeURIComponent ( key ) ; value = encodeURIComponent ( value ) ; // // If we failed to encode the strings, we should bail out as we don't // want to add invalid strings to the query. // if ( key === null || value === null ) continue ; pairs . push ( key + '=' + value ) ; } } return pairs . length ? prefix + pairs . join ( '&' ) : '' ; }
Transform a query string to an object.

@param {Object} obj Object that should be transformed.
@param {String} prefix Optional prefix.
@returns {String}
@api public
Transform a query string to an object .