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

Commit c5bf9da

Browse files
Utsav ShahNarretz
Utsav Shah
authored andcommitted
fix($http): throw if url passed is not a string
Throw to prevent hard to debug errors in functions that are called later. Fixes #12925 Closes #13444
1 parent be01ceb commit c5bf9da

File tree

2 files changed

+11
-0
lines changed

2 files changed

+11
-0
lines changed

src/ng/http.js

+4
Original file line numberDiff line numberDiff line change
@@ -918,6 +918,10 @@ function $HttpProvider() {
918918
throw minErr('$http')('badreq', 'Http request configuration must be an object. Received: {0}', requestConfig);
919919
}
920920

921+
if (!isString(requestConfig.url)) {
922+
throw minErr('$http')('badreq', 'Http request configuration url must be a string. Received: {0}', requestConfig.url);
923+
}
924+
921925
var config = extend({
922926
method: 'get',
923927
transformRequest: defaults.transformRequest,

test/ng/httpSpec.js

+7
Original file line numberDiff line numberDiff line change
@@ -302,6 +302,13 @@ describe('$http', function() {
302302
}).toThrowMinErr('$http','badreq', 'Http request configuration must be an object. Received: /url');
303303
});
304304

305+
it('should throw error if the request configuration url is not a string', function() {
306+
expect(function() {
307+
$http({url: false});
308+
}).toThrowMinErr('$http','badreq', 'Http request configuration url must be a string. Received: false');
309+
});
310+
311+
305312
it('should send GET requests if no method specified', function() {
306313
$httpBackend.expect('GET', '/url').respond('');
307314
$http({url: '/url'});

0 commit comments

Comments
 (0)