This repository was archived by the owner on Apr 12, 2024. It is now read-only.
File tree 2 files changed +15
-0
lines changed
2 files changed +15
-0
lines changed Original file line number Diff line number Diff line change @@ -417,6 +417,12 @@ LocationHashbangInHtml5Url.prototype =
417
417
if ( isString ( search ) ) {
418
418
this . $$search = parseKeyValue ( search ) ;
419
419
} else if ( isObject ( search ) ) {
420
+ // remove object undefined or null properties
421
+ Object . keys ( search ) . forEach ( function ( key ) {
422
+ if ( isUndefined ( search [ key ] ) || search [ key ] === null ) {
423
+ delete search [ key ] ;
424
+ }
425
+ } ) ;
420
426
this . $$search = search ;
421
427
} else {
422
428
throw $locationMinErr ( 'isrcharg' ,
Original file line number Diff line number Diff line change @@ -117,6 +117,15 @@ describe('$location', function() {
117
117
} ) ;
118
118
119
119
120
+ it ( 'search() should remove multiple parameters' , function ( ) {
121
+ url . search ( { one : 1 , two : true } ) ;
122
+ expect ( url . search ( ) ) . toEqual ( { one : 1 , two : true } ) ;
123
+ url . search ( { one : null , two : null } ) ;
124
+ expect ( url . search ( ) ) . toEqual ( { } ) ;
125
+ expect ( url . absUrl ( ) ) . toBe ( 'http://www.domain.com:9877/path/b#hash' ) ;
126
+ } ) ;
127
+
128
+
120
129
it ( 'search() should handle multiple value' , function ( ) {
121
130
url . search ( 'a&b' ) ;
122
131
expect ( url . search ( ) ) . toEqual ( { a : true , b : true } ) ;
You can’t perform that action at this time.
0 commit comments