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

Commit c8e03e3

Browse files
just-borisIgorMinar
authored andcommitted
fix($http): do not add trailing question
Closes #6342
1 parent 267b217 commit c8e03e3

File tree

3 files changed

+10
-2
lines changed

3 files changed

+10
-2
lines changed

src/ng/http.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1026,7 +1026,10 @@ function $HttpProvider() {
10261026
encodeUriQuery(v));
10271027
});
10281028
});
1029-
return url + ((url.indexOf('?') == -1) ? '?' : '&') + parts.join('&');
1029+
if(parts.length > 0) {
1030+
url += ((url.indexOf('?') == -1) ? '?' : '&') + parts.join('&');
1031+
}
1032+
return url;
10301033
}
10311034

10321035

test/ng/httpSpec.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -456,6 +456,11 @@ describe('$http', function() {
456456
$httpBackend.expect('GET', '/Path?!do%26h=g%3Da+h&:bar=$baz@1').respond('');
457457
$http({url: '/Path', params: {':bar': '$baz@1', '!do&h': 'g=a h'}, method: 'GET'});
458458
});
459+
460+
it('should not add question mark when params is empty', function() {
461+
$httpBackend.expect('GET', '/url').respond('');
462+
$http({url: '/url', params: {}, method: 'GET'});
463+
})
459464
});
460465

461466

test/ngResource/resourceSpec.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -330,7 +330,7 @@ describe("resource", function() {
330330

331331

332332
it('should not throw TypeError on null default params', function() {
333-
$httpBackend.expect('GET', '/Path?').respond('{}');
333+
$httpBackend.expect('GET', '/Path').respond('{}');
334334
var R = $resource('/Path', {param: null}, {get: {method: 'GET'}});
335335

336336
expect(function() {

0 commit comments

Comments
 (0)