Skip to content

Commit

Permalink
Add defensive if statements to valuesIn and valuesNotIn filters
Browse files Browse the repository at this point in the history
  • Loading branch information
benjaminapetersen committed May 9, 2016
1 parent 71f310b commit 6d64d7c
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
12 changes: 9 additions & 3 deletions assets/app/scripts/filters/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,9 @@ angular.module('openshiftConsole')
*/
.filter("valuesIn", function(){
return function(entries, keys){
if (!keys) {
return {};
}
var readonly = keys.split(",");
var result = {};
angular.forEach(entries, function(value, key){
Expand All @@ -273,6 +276,9 @@ angular.module('openshiftConsole')
*/
.filter("valuesNotIn", function(){
return function(entries, keys){
if (!keys) {
return entries;
}
var readonly = keys.split(",");
var result = {};
angular.forEach(entries, function(value, key){
Expand Down Expand Up @@ -369,7 +375,7 @@ angular.module('openshiftConsole')
catch (e) {
// it wasn't valid json
return null;
}
}
};
})
.filter('prettifyJSON', function(parseJSONFilter) {
Expand Down Expand Up @@ -422,7 +428,7 @@ angular.module('openshiftConsole')
return function(value, format) {
if (!value) {
return value;
}
}
var accessModes = [];
angular.forEach(value, function(item) {
var accessModeString;
Expand Down Expand Up @@ -470,7 +476,7 @@ angular.module('openshiftConsole')
if (lastSpace !== -1) {
truncated = truncated.substring(0, lastSpace);
}
}
}

return truncated;
};
Expand Down
2 changes: 2 additions & 0 deletions pkg/assets/bindata.go
Original file line number Diff line number Diff line change
Expand Up @@ -9303,13 +9303,15 @@ return a ? "Yes" :"No";
};
}).filter("valuesIn", function() {
return function(a, b) {
if (!b) return {};
var c = b.split(","), d = {};
return angular.forEach(a, function(a, b) {
-1 !== c.indexOf(b) && (d[b] = a);
}), d;
};
}).filter("valuesNotIn", function() {
return function(a, b) {
if (!b) return a;
var c = b.split(","), d = {};
return angular.forEach(a, function(a, b) {
-1 === c.indexOf(b) && (d[b] = a);
Expand Down

0 comments on commit 6d64d7c

Please sign in to comment.