dist/uri.js.js
function(url, decode) {

      // If we're passed an object, convert it to a string
      if (typeof url === 'object') url = url.toString();

      // Default decode to true
      if (typeof decode === 'undefined') decode = true;

      // Extract query string from url
      var query_string = this.search(url);

      // Replace the starting ?, if it is there
      query_string = query_string.replace(/^\?/, '');

      var parts;

      // If query string is blank, parts should be blank
      if (query_string === '') {
        parts = [];
      } else {
        // Split the query string into key value parts
        parts = query_string.split('&');
      }

      // Iniate the return value
      var query = {};

      // Loop through each other the parts, splitting it into keys and values
      for (var i = 0, l = parts.length; i < l; i++) {
        var part = parts[i];
        var key;
        var val = '';

        if (part.match('=')) {
          // If it is in the format key=val

          // Split into the key and value by the = symbol
          var part_parts = part.split('=');

          // Assign key and value
          key = part_parts[0];
          val = part_parts[1];
        } else {
          // If there is no value, just set the key to the full part
          key = part;
        }

        // If we actually have a value, URI decode it
        if (val !== '' && decode) {
          val = decodeURIComponent(val);
        }

        // Assign to the return value
        query[key] = val;
      }

      return query;
    }
function(url, decode) {

      // If we're passed an object, convert it to a string
      if (typeof url === 'object') url = url.toString();

      // Default decode to true
      if (typeof decode === 'undefined') decode = true;

      // Extract query string from url
      var query_string = this.search(url);

      // Replace the starting ?, if it is there
      query_string = query_string.replace(/^\?/, '');

      var parts;

      // If query string is blank, parts should be blank
      if (query_string === '') {
        parts = [];
      } else {
        // Split the query string into key value parts
        parts = query_string.split('&');
      }

      // Iniate the return value
      var query = {};

      // Loop through each other the parts, splitting it into keys and values
      for (var i = 0, l = parts.length; i < l; i++) {
        var part = parts[i];
        var key;
        var val = '';

        if (part.match('=')) {
          // If it is in the format key=val

          // Split into the key and value by the = symbol
          var part_parts = part.split('=');

          // Assign key and value
          key = part_parts[0];
          val = part_parts[1];
        } else {
          // If there is no value, just set the key to the full part
          key = part;
        }

        // If we actually have a value, URI decode it
        if (val !== '' && decode) {
          val = decodeURIComponent(val);
        }

        // Assign to the return value
        query[key] = val;
      }

      return query;
    }
function ( url , decode ) { // If we're passed an object, convert it to a string if ( typeof url === 'object' ) url = url . toString ( ) ; // Default decode to true if ( typeof decode === 'undefined' ) decode = true ; // Extract query string from url var query_string = this . search ( url ) ; // Replace the starting ?, if it is there query_string = query_string . replace ( / ^\? / , '' ) ; var parts ; // If query string is blank, parts should be blank if ( query_string === '' ) { parts = [ ] ; } else { // Split the query string into key value parts parts = query_string . split ( '&' ) ; } // Iniate the return value var query = { } ; // Loop through each other the parts, splitting it into keys and values for ( var i = 0 , l = parts . length ; i < l ; i ++ ) { var part = parts [ i ] ; var key ; var val = '' ; if ( part . match ( '=' ) ) { // If it is in the format key=val // Split into the key and value by the = symbol var part_parts = part . split ( '=' ) ; // Assign key and value key = part_parts [ 0 ] ; val = part_parts [ 1 ] ; } else { // If there is no value, just set the key to the full part key = part ; } // If we actually have a value, URI decode it if ( val !== '' && decode ) { val = decodeURIComponent ( val ) ; } // Assign to the return value query [ key ] = val ; } return query ; }
Parse URI query strings
@param  {string} url        The URL or query string to parse
@param  {bool}   decode     Should values be URI decoded?
@return {object}            The parsed query string
Parse URI query strings