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 @@ -111,7 +111,9 @@ function $HttpParamSerializerJQLikeProvider() {
111
111
forEach ( toSerialize , function ( value ) {
112
112
serialize ( value , prefix + '[]' ) ;
113
113
} ) ;
114
- } else if ( isObject ( toSerialize ) && ! isDate ( toSerialize ) ) {
114
+ } else if ( isFunction ( toSerialize . toJSON ) ) {
115
+ parts . push ( encodeUriQuery ( prefix ) + '=' + encodeUriQuery ( toSerialize . toJSON ( ) ) ) ;
116
+ } else if ( isObject ( toSerialize ) ) {
115
117
forEachSorted ( toSerialize , function ( value , key ) {
116
118
serialize ( value , prefix +
117
119
( topLevel ? '' : '[' ) +
Original file line number Diff line number Diff line change @@ -1999,6 +1999,20 @@ describe('$http param serializers', function() {
1999
1999
expect ( jqrSer ( { someDate : new Date ( '2014-07-15T17:30:00.000Z' ) } ) ) . toEqual ( 'someDate=2014-07-15T17:30:00.000Z' ) ;
2000
2000
} ) ;
2001
2001
2002
+ it ( 'should honor toJSON function' , function ( ) {
2003
+ expect ( jqrSer ( {
2004
+ foo : {
2005
+ a : 'b' ,
2006
+ toJSON : function ( ) {
2007
+ return 'baz' ;
2008
+ }
2009
+ } ,
2010
+ bar : {
2011
+ c : 'd'
2012
+ }
2013
+ } ) ) . toEqual ( 'bar%5Bc%5D=d&foo=baz' ) ;
2014
+ } ) ;
2015
+
2002
2016
} ) ;
2003
2017
2004
2018
describe ( 'default array serialization' , function ( ) {
You can’t perform that action at this time.
0 commit comments