This repository was archived by the owner on Apr 12, 2024. It is now read-only.
File tree 2 files changed +14
-8
lines changed
2 files changed +14
-8
lines changed Original file line number Diff line number Diff line change @@ -1062,14 +1062,16 @@ function parseKeyValue(/**string*/keyValue) {
1062
1062
function toKeyValue ( obj ) {
1063
1063
var parts = [ ] ;
1064
1064
forEach ( obj , function ( value , key ) {
1065
- if ( isArray ( value ) ) {
1066
- forEach ( value , function ( arrayValue ) {
1067
- parts . push ( encodeUriQuery ( key , true ) +
1068
- ( arrayValue === true ? '' : '=' + encodeUriQuery ( arrayValue , true ) ) ) ;
1069
- } ) ;
1070
- } else {
1071
- parts . push ( encodeUriQuery ( key , true ) +
1072
- ( value === true ? '' : '=' + encodeUriQuery ( value , true ) ) ) ;
1065
+ if ( value !== null ) {
1066
+ if ( isArray ( value ) ) {
1067
+ forEach ( value , function ( arrayValue ) {
1068
+ parts . push ( encodeUriQuery ( key , true ) +
1069
+ ( arrayValue === true ? '' : '=' + encodeUriQuery ( arrayValue , true ) ) ) ;
1070
+ } ) ;
1071
+ } else {
1072
+ parts . push ( encodeUriQuery ( key , true ) +
1073
+ ( value === true ? '' : '=' + encodeUriQuery ( value , true ) ) ) ;
1074
+ }
1073
1075
}
1074
1076
} ) ;
1075
1077
return parts . length ? parts . join ( '&' ) : '' ;
Original file line number Diff line number Diff line change @@ -491,6 +491,10 @@ describe('angular', function() {
491
491
expect ( toKeyValue ( { key : [ 323 , 'value' , true , 1234 ] } ) ) .
492
492
toEqual ( 'key=323&key=value&key&key=1234' ) ;
493
493
} ) ;
494
+
495
+ it ( 'should not serialize null values' , function ( ) {
496
+ expect ( toKeyValue ( { nullKey : null , key : 'value' } ) ) . toEqual ( 'key=value' ) ;
497
+ } ) ;
494
498
} ) ;
495
499
496
500
You can’t perform that action at this time.
0 commit comments