Skip to content
This repository has been archived by the owner on Nov 10, 2017. It is now read-only.

Commit

Permalink
Bug 1110892 - fixed array handling issues on query params
Browse files Browse the repository at this point in the history
When we have multiple values for the same query param,
not all the code was creating an array for the values.  The deparam was
just giving you the last one in the list.
  • Loading branch information
Cameron Dawson committed Dec 12, 2014
1 parent 9efb1a2 commit 01e56db
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 4 deletions.
4 changes: 2 additions & 2 deletions webapp/app/js/services/jobfilters.js
Expand Up @@ -492,8 +492,8 @@ treeherder.factory('thJobFilters', [
* check if we're in the state of showing only unclassified failures
*/
var _isUnclassifiedFailures = function() {
return (_.isEqual($location.search()[QS_RESULT_STATUS], thFailureResults) &&
_.isEqual($location.search()[QS_CLASSIFIED_STATE], ['unclassified']));
return (_.isEqual(_toArray($location.search()[QS_RESULT_STATUS]), thFailureResults) &&
_.isEqual(_toArray($location.search()[QS_CLASSIFIED_STATE]), ['unclassified']));
};

var _matchesDefaults = function(field, values) {
Expand Down
15 changes: 13 additions & 2 deletions webapp/app/vendor/jquery.deparam.js
@@ -1,8 +1,10 @@
/**
* jQuery.deparam - The oposite of jQuery param. Creates an object of query string parameters.
*
*
* Credits for the idea and Regex:
* http://stevenbenner.com/2010/03/javascript-regex-trick-parse-a-query-string-into-an-object/
*
* :camd - added support for multiple values of the same param
*/
(function($){
$.deparam = $.deparam || function(uri){
Expand All @@ -13,7 +15,16 @@
uri.replace(
new RegExp(
"([^?=&]+)(=([^&#]*))?", "g"),
function($0, $1, $2, $3) { queryString[$1] = $3; }
function($0, $1, $2, $3) {
if (queryString.hasOwnProperty($1)) {
if (!$.isArray(queryString[$1])) {
queryString[$1] = [queryString[$1]]
}
queryString[$1].push($3);
} else {
queryString[$1] = $3;
}
}
);
return queryString;
};
Expand Down

0 comments on commit 01e56db

Please sign in to comment.