From b019a48bb1176f3c9ce29b628a321b6ffe873393 Mon Sep 17 00:00:00 2001 From: Jeff Cross Date: Thu, 25 Jul 2013 10:53:43 -0700 Subject: 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 --- src/ng/http.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src/ng/http.js') diff --git a/src/ng/http.js b/src/ng/http.js index 8fdc0708..de8e6b6d 100644 --- a/src/ng/http.js +++ b/src/ng/http.js @@ -132,8 +132,8 @@ function $HttpProvider() { */ var responseInterceptorFactories = this.responseInterceptors = []; - this.$get = ['$httpBackend', '$browser', '$cacheFactory', '$rootScope', '$q', '$injector', '$$urlUtils', - function($httpBackend, $browser, $cacheFactory, $rootScope, $q, $injector, $$urlUtils) { + this.$get = ['$httpBackend', '$browser', '$cacheFactory', '$rootScope', '$q', '$injector', + function($httpBackend, $browser, $cacheFactory, $rootScope, $q, $injector) { var defaultCache = $cacheFactory('$http'); @@ -649,7 +649,7 @@ function $HttpProvider() { config.headers = headers; config.method = uppercase(config.method); - var xsrfValue = $$urlUtils.isSameOrigin(config.url) + var xsrfValue = urlIsSameOrigin(config.url) ? $browser.cookies()[config.xsrfCookieName || defaults.xsrfCookieName] : undefined; if (xsrfValue) { -- cgit v1.2.3