From 4266de43a3e075d987880122d13a1ce32bbbc085 Mon Sep 17 00:00:00 2001 From: Utsav Shah Date: Thu, 3 Dec 2015 10:30:48 -0600 Subject: [PATCH] feat(http): Check if url passed in is String Checks early on if the url passed in is a string or not. Fixes #12925 --- src/ng/http.js | 4 ++++ test/ng/httpSpec.js | 7 +++++++ 2 files changed, 11 insertions(+) diff --git a/src/ng/http.js b/src/ng/http.js index 81ad9e699bcc..4c2a412133c9 100644 --- a/src/ng/http.js +++ b/src/ng/http.js @@ -918,6 +918,10 @@ function $HttpProvider() { throw minErr('$http')('badreq', 'Http request configuration must be an object. Received: {0}', requestConfig); } + if (!isString(requestConfig.url)) { + throw minErr('$http')('badreq', 'Http request configuration url must be a string. Received: {0}', requestConfig.url); + } + var config = extend({ method: 'get', transformRequest: defaults.transformRequest, diff --git a/test/ng/httpSpec.js b/test/ng/httpSpec.js index 7942dd9d567e..90577852828b 100644 --- a/test/ng/httpSpec.js +++ b/test/ng/httpSpec.js @@ -302,6 +302,13 @@ describe('$http', function() { }).toThrowMinErr('$http','badreq', 'Http request configuration must be an object. Received: /url'); }); + it('should throw error if the request configuration url is not a string', function() { + expect(function() { + $http({ url : false}); + }).toThrowMinErr('$http','badreq', 'Http request configuration url must be a string. Received: false'); + }); + + it('should send GET requests if no method specified', function() { $httpBackend.expect('GET', '/url').respond(''); $http({url: '/url'});