File tree 2 files changed +14
-0
lines changed
2 files changed +14
-0
lines changed Original file line number Diff line number Diff line change @@ -446,6 +446,11 @@ LocationHashbangInHtml5Url.prototype =
446
446
if ( isString ( search ) ) {
447
447
this . $$search = parseKeyValue ( search ) ;
448
448
} else if ( isObject ( search ) ) {
449
+ // remove object undefined or null properties
450
+ forEach ( search , function ( value , key ) {
451
+ if ( value == null ) delete search [ key ] ;
452
+ } ) ;
453
+
449
454
this . $$search = search ;
450
455
} else {
451
456
throw $locationMinErr ( 'isrcharg' ,
Original file line number Diff line number Diff line change @@ -118,6 +118,15 @@ describe('$location', function() {
118
118
} ) ;
119
119
120
120
121
+ it ( 'search() should remove multiple parameters' , function ( ) {
122
+ url . search ( { one : 1 , two : true } ) ;
123
+ expect ( url . search ( ) ) . toEqual ( { one : 1 , two : true } ) ;
124
+ url . search ( { one : null , two : null } ) ;
125
+ expect ( url . search ( ) ) . toEqual ( { } ) ;
126
+ expect ( url . absUrl ( ) ) . toBe ( 'http://www.domain.com:9877/path/b#hash' ) ;
127
+ } ) ;
128
+
129
+
121
130
it ( 'search() should handle multiple value' , function ( ) {
122
131
url . search ( 'a&b' ) ;
123
132
expect ( url . search ( ) ) . toEqual ( { a : true , b : true } ) ;
You can’t perform that action at this time.
0 commit comments