diff --git a/src/ng/http.js b/src/ng/http.js index f009acd8de83..6c0557385640 100644 --- a/src/ng/http.js +++ b/src/ng/http.js @@ -1,4 +1,4 @@ -'use strict'; +'use strict'; /** * Parse headers into key value object @@ -990,7 +990,12 @@ function $HttpProvider() { forEach(value, function(v) { if (isObject(v)) { - v = toJson(v); + if (v instanceof Date){ + v = v.toISOString(); //toISOString() only supported in IE8 and above + } + else if (isObject(v)) { + v = toJson(v); + } } parts.push(encodeUriQuery(key) + '=' + encodeUriQuery(v)); diff --git a/test/ng/httpSpec.js b/test/ng/httpSpec.js index 410bb502a779..9547c32d1763 100644 --- a/test/ng/httpSpec.js +++ b/test/ng/httpSpec.js @@ -341,6 +341,11 @@ describe('$http', function() { $httpBackend.expect('GET', '/url').respond(''); $http({url: '/url', params: {}, method: 'GET'}); }); + + it('should not double quote dates', function() { + $httpBackend.expect('GET', '/url?date=2014-07-15T17:30:00.000Z').respond(''); + $http({url: '/url', params: {date:new Date('2014-07-15T17:30:00.000Z')}, method: 'GET'}); + }); });