aboutsummaryrefslogtreecommitdiffstats
path: root/src/ng/httpBackend.js
diff options
context:
space:
mode:
authorJeff Cross2013-07-25 10:53:43 -0700
committerIgor Minar2013-10-10 11:41:07 -0700
commitb019a48bb1176f3c9ce29b628a321b6ffe873393 (patch)
treee1b06b53d3806019b9386acd532153ea14ff7c26 /src/ng/httpBackend.js
parent74ef7f14a49662ebf389a515b86e6dd68e746811 (diff)
downloadangular.js-b019a48bb1176f3c9ce29b628a321b6ffe873393.tar.bz2
refactor(location): $location now uses urlUtils, not RegEx
The location service, and other portions of the application, were relying on a complicated regular expression to get parts of a URL. But there is already a private urlUtils provider, which relies on HTMLAnchorElement to provide this information, and is suitable for most cases. In order to make urlUtils more accessible in the absence of DI, its methods were converted to standalone functions available globally. The urlUtils.resolve method was renamed urlResolve, and was refactored to only take 1 argument, url, and not the 2nd "parse" boolean. The method now always returns a parsed url. All places in code which previously wanted a string instead of a parsed url can now get the value from the href property of the returned object. Tests were also added to ensure IPv6 addresses were handled correctly. Closes #3533 Closes #2950 Closes #3249
Diffstat (limited to 'src/ng/httpBackend.js')
-rw-r--r--src/ng/httpBackend.js3
1 files changed, 1 insertions, 2 deletions
diff --git a/src/ng/httpBackend.js b/src/ng/httpBackend.js
index 3e7406b0..55ea5607 100644
--- a/src/ng/httpBackend.js
+++ b/src/ng/httpBackend.js
@@ -102,8 +102,7 @@ function createHttpBackend($browser, XHR, $browserDefer, callbacks, rawDocument,
}
function completeRequest(callback, status, response, headersString) {
- // URL_MATCH is defined in src/service/location.js
- var protocol = (url.match(SERVER_MATCH) || ['', locationProtocol])[1];
+ var protocol = locationProtocol || urlResolve(url).protocol;
// cancel timeout and subsequent timeout promise resolution
timeoutId && $browserDefer.cancel(timeoutId);