This repository was archived by the owner on Apr 12, 2024. It is now read-only.
File tree 2 files changed +15
-9
lines changed
2 files changed +15
-9
lines changed Original file line number Diff line number Diff line change @@ -1085,14 +1085,16 @@ function parseKeyValue(/**string*/keyValue) {
1085
1085
function toKeyValue ( obj ) {
1086
1086
var parts = [ ] ;
1087
1087
forEach ( obj , function ( value , key ) {
1088
- if ( isArray ( value ) ) {
1089
- forEach ( value , function ( arrayValue ) {
1090
- parts . push ( encodeUriQuery ( key , true ) +
1091
- ( arrayValue === true ? '' : '=' + encodeUriQuery ( arrayValue , true ) ) ) ;
1092
- } ) ;
1093
- } else {
1094
- parts . push ( encodeUriQuery ( key , true ) +
1095
- ( value === true ? '' : '=' + encodeUriQuery ( value , true ) ) ) ;
1088
+ if ( value !== null ) {
1089
+ if ( isArray ( value ) ) {
1090
+ forEach ( value , function ( arrayValue ) {
1091
+ parts . push ( encodeUriQuery ( key , true ) +
1092
+ ( arrayValue === true ? '' : '=' + encodeUriQuery ( arrayValue , true ) ) ) ;
1093
+ } ) ;
1094
+ } else {
1095
+ parts . push ( encodeUriQuery ( key , true ) +
1096
+ ( value === true ? '' : '=' + encodeUriQuery ( value , true ) ) ) ;
1097
+ }
1096
1098
}
1097
1099
} ) ;
1098
1100
return parts . length ? parts . join ( '&' ) : '' ;
Original file line number Diff line number Diff line change @@ -457,7 +457,11 @@ describe('angular', function() {
457
457
expect ( toKeyValue ( { key : [ 323 , 'value' , true ] } ) ) . toEqual ( 'key=323&key=value&key' ) ;
458
458
expect ( toKeyValue ( { key : [ 323 , 'value' , true , 1234 ] } ) ) .
459
459
toEqual ( 'key=323&key=value&key&key=1234' ) ;
460
- } ) ;
460
+ } ) ;
461
+
462
+ it ( 'should not serialize null values' , function ( ) {
463
+ expect ( toKeyValue ( { nullKey : null , key : 'value' } ) ) . toEqual ( 'key=value' ) ;
464
+ } ) ;
461
465
} ) ;
462
466
463
467
You can’t perform that action at this time.
0 commit comments