Skip to content
This repository has been archived by the owner on Apr 12, 2024. It is now read-only.

Commit

Permalink
fix($http): do not add trailing question
Browse files Browse the repository at this point in the history
Closes #6342
  • Loading branch information
just-boris authored and IgorMinar committed Feb 21, 2014
1 parent 267b217 commit c8e03e3
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 2 deletions.
5 changes: 4 additions & 1 deletion src/ng/http.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}


Expand Down
5 changes: 5 additions & 0 deletions test/ng/httpSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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'});
})
});


Expand Down
2 changes: 1 addition & 1 deletion test/ngResource/resourceSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down

0 comments on commit c8e03e3

Please sign in to comment.