diff --git a/src/ng/http.js b/src/ng/http.js index defe43dc634f..6394819691ef 100644 --- a/src/ng/http.js +++ b/src/ng/http.js @@ -1026,7 +1026,10 @@ function $HttpProvider() { encodeUriQuery(v)); }); }); - return url + ((url.indexOf('?') == -1) ? '?' : '&') + parts.join('&'); + if(parts.length > 0) { + url += ((url.indexOf('?') == -1) ? '?' : '&') + parts.join('&'); + } + return url; } diff --git a/test/ng/httpSpec.js b/test/ng/httpSpec.js index d446a80cefda..192fde5c3a45 100644 --- a/test/ng/httpSpec.js +++ b/test/ng/httpSpec.js @@ -456,6 +456,11 @@ describe('$http', function() { $httpBackend.expect('GET', '/Path?!do%26h=g%3Da+h&:bar=$baz@1').respond(''); $http({url: '/Path', params: {':bar': '$baz@1', '!do&h': 'g=a h'}, method: 'GET'}); }); + + it('should not add question mark when params is empty', function() { + $httpBackend.expect('GET', '/url').respond(''); + $http({url: '/url', params: {}, method: 'GET'}); + }) }); diff --git a/test/ngResource/resourceSpec.js b/test/ngResource/resourceSpec.js index 1c0b73b9d158..13317155fa21 100644 --- a/test/ngResource/resourceSpec.js +++ b/test/ngResource/resourceSpec.js @@ -330,7 +330,7 @@ describe("resource", function() { it('should not throw TypeError on null default params', function() { - $httpBackend.expect('GET', '/Path?').respond('{}'); + $httpBackend.expect('GET', '/Path').respond('{}'); var R = $resource('/Path', {param: null}, {get: {method: 'GET'}}); expect(function() {