Skip to content

Commit 7e49d37

Browse files
committed
fix($$urlUtils): remove dependency on $window
$window may be mocked out in tests causing those tests to fail. So don't use $window.
1 parent dfa8347 commit 7e49d37

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

src/ng/urlUtils.js

+7-2
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,14 @@
11
'use strict';
22

33
function $$UrlUtilsProvider() {
4-
this.$get = ['$window', '$document', function($window, $document) {
4+
this.$get = ['$document', function($document) {
55
var urlParsingNode = $document[0].createElement("a"),
6-
originUrl = resolve($window.location.href, true);
6+
// NOTE: The usage of window instead of $window here is deliberate. When the browser
7+
// resolves a URL for XHR, it doesn't know about any mocked $window. $$urlUtils
8+
// resolves URLs just as the browser would. Using $window here would confuse the
9+
// isSameOrigin check causing unexpected failures. We avoid that by using the real window
10+
// object.
11+
originUrl = resolve(window.location.href, true);
712

813
/**
914
* @description

0 commit comments

Comments
 (0)