This repository was archived by the owner on Apr 12, 2024. It is now read-only.
File tree 2 files changed +17
-1
lines changed
2 files changed +17
-1
lines changed Original file line number Diff line number Diff line change @@ -117,7 +117,9 @@ function $HttpParamSerializerJQLikeProvider() {
117
117
forEach ( toSerialize , function ( value , index ) {
118
118
serialize ( value , prefix + '[' + ( isObject ( value ) ? index : '' ) + ']' ) ;
119
119
} ) ;
120
- } else if ( isObject ( toSerialize ) && ! isDate ( toSerialize ) ) {
120
+ } else if ( isFunction ( toSerialize . toJSON ) ) {
121
+ parts . push ( encodeUriQuery ( prefix ) + '=' + encodeUriQuery ( toSerialize . toJSON ( ) ) ) ;
122
+ } else if ( isObject ( toSerialize ) ) {
121
123
forEachSorted ( toSerialize , function ( value , key ) {
122
124
serialize ( value , prefix +
123
125
( topLevel ? '' : '[' ) +
Original file line number Diff line number Diff line change @@ -2030,6 +2030,20 @@ describe('$http param serializers', function() {
2030
2030
expect ( jqrSer ( { someDate : new Date ( '2014-07-15T17:30:00.000Z' ) } ) ) . toEqual ( 'someDate=2014-07-15T17:30:00.000Z' ) ;
2031
2031
} ) ;
2032
2032
2033
+ it ( 'should honor toJSON function' , function ( ) {
2034
+ expect ( jqrSer ( {
2035
+ foo : {
2036
+ a : 'b' ,
2037
+ toJSON : function ( ) {
2038
+ return 'baz' ;
2039
+ }
2040
+ } ,
2041
+ bar : {
2042
+ c : 'd'
2043
+ }
2044
+ } ) ) . toEqual ( 'bar%5Bc%5D=d&foo=baz' ) ;
2045
+ } ) ;
2046
+
2033
2047
} ) ;
2034
2048
2035
2049
describe ( 'default array serialization' , function ( ) {
You can’t perform that action at this time.
0 commit comments