Skip to content

Commit

Permalink
Fix issue where it only worked with a querystring
Browse files Browse the repository at this point in the history
  • Loading branch information
darlesson committed Apr 29, 2015
1 parent 9802b38 commit d2a9cd8
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 33 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ Download the files and add the following to your website
<script type="text/javascript" src="javascript/jquery-1.4.2.min.js"></script>
// Insert the source file
<script type="text/javascript" src="source/querystring-1.1.0.js"></script>
<script type="text/javascript" src="source/querystring-1.1.1.js"></script>
```

## Usage ##
Expand Down
67 changes: 35 additions & 32 deletions source/querystring-1.1.0.js → source/querystring-1.1.1.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*!
* jQuery QueryString v1.1.0 (Release version)
* jQuery QueryString v1.1.1 (Release version)
*
* http://www.darlesson.com/
*
Expand Down Expand Up @@ -59,51 +59,54 @@
multipleAsArray = options.multipleAsArray,
href = options.href.toString(),
queryString = (href.lastIndexOf("?") > -1) ? href.substring(href.lastIndexOf("?") + 1, href.length) : null,
items = [],
indexOfHash = queryString.lastIndexOf('#');
items = [];

// Remove hash from the return
if (indexOfHash)
queryString = queryString.substring(0, indexOfHash);
if (queryString) {

if (queryString)
items = queryString.split('&');
var indexOfHash = queryString.lastIndexOf('#');

if (items.length) {
// Remove hash from the return
if (indexOfHash > -1)
queryString = queryString.substring(0, indexOfHash);

var i = -1,
item = '',
indexOfEqual = -1,
hasOwnProperty = false,
key,
value;
while (i++ && i < items.length || i < items.length) {
if (queryString)
items = queryString.split('&');

item = items[i];
if (items.length) {

indexOfEqual = item.indexOf('=');
var i = -1,
item = '',
indexOfEqual = -1,
hasOwnProperty = false,
key,
value;
while (i++ && i < items.length || i < items.length) {

if (indexOfEqual > 0) {
item = items[i];

key = item.substring(0, indexOfEqual);
value = item.substring(indexOfEqual + 1);
hasOwnProperty = this.parameters.hasOwnProperty(key);
indexOfEqual = item.indexOf('=');

if (multipleAsArray && hasOwnProperty) {
if (indexOfEqual > 0) {

// Make the value an array
if (typeof this.parameters[key] === 'string')
this.parameters[key] = [this.parameters[key]];
key = item.substring(0, indexOfEqual);
value = item.substring(indexOfEqual + 1);
hasOwnProperty = this.parameters.hasOwnProperty(key);

this.parameters[key].push(value);
if (multipleAsArray && hasOwnProperty) {

} else if (!hasOwnProperty)
this.parameters[key] = value;
// Make the value an array
if (typeof this.parameters[key] === 'string')
this.parameters[key] = [this.parameters[key]];

this.size++;
this.parameters[key].push(value);

} else if (!hasOwnProperty)
this.parameters[key] = value;

this.size++;
}
}
}

}
};

Expand Down Expand Up @@ -187,4 +190,4 @@

};

})(jQuery);
})(jQuery);

0 comments on commit d2a9cd8

Please sign in to comment.