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

Commit bf1b540

Browse files
committed
review feedback
1 parent 0c20c75 commit bf1b540

File tree

4 files changed

+13
-12
lines changed

4 files changed

+13
-12
lines changed

src/ng/urlUtils.js

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ function urlIsSameOrigin(requestUrl) {
9898
* Parse a request URL and determine whether it is same-origin as the current document base URL.
9999
*
100100
* Note: The base URL is usually the same the document location (`location.href`) but can
101-
* overriden by using the `<base>` tag.
101+
* be overriden by using the `<base>` tag.
102102
*
103103
* @param {string|object} requestUrl The url of the request as a string that will be resolved
104104
* or a parsed URL object.
@@ -113,18 +113,18 @@ function urlIsSameOriginAsBaseUrl(requestUrl) {
113113
/**
114114
* Determines if two URLs share the same origin.
115115
*
116-
* @param {object} url1 First URL to compare. Must be a normalized URL in the form of a
117-
* dictionary object returned by `urlResolve()`.
118-
* @param {object} url2 Second URL to compare. Must be a normalized URL in the form of a
119-
* dictionary object returned by `urlResolve()`.
116+
* @param {string|object} url1 First URL to compare as a string or a normalized URL in the form of
117+
* a dictionary object returned by `urlResolve()`.
118+
* @param {string|object} url2 Second URL to compare as a string or a normalized URL in the form of
119+
* a dictionary object returned by `urlResolve()`.
120120
* @return {boolean} True if both URLs have the same origin, and false otherwise.
121121
*/
122122
function urlsAreSameOrigin(url1, url2) {
123-
// IE sometimes includes a port in the 'host' property, even if it is the default 80 port so
124-
// we check hostname and port separately.
125-
return url1.protocol === url2.protocol &&
126-
url1.hostname === url2.hostname &&
127-
url1.port === url2.port;
123+
url1 = (isString(url1)) ? urlResolve(url1) : url1;
124+
url2 = (isString(url2)) ? urlResolve(url2) : url2;
125+
126+
return (url1.protocol === url2.protocol &&
127+
url1.host === url2.host);
128128
}
129129

130130
/**

test/e2e/fixtures/base_tag/index.html renamed to test/e2e/fixtures/base-tag/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<head>
44
<base href="http://www.example.com/">
55
<script src="http://localhost:8000/build/angular.js"></script>
6-
<script src="http://localhost:8000/e2e/fixtures/base_tag/script.js"></script>
6+
<script src="http://localhost:8000/e2e/fixtures/base-tag/script.js"></script>
77
</head>
88
<body>
99
</body>

test/e2e/tests/base_tag.spec.js renamed to test/e2e/tests/base-tag.spec.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ describe('SCE URL policy when base tags are present', function() {
77
}
88

99
beforeAll(function() {
10-
loadFixture('base_tag');
10+
loadFixture('base-tag');
1111
});
1212

1313
it('allows the page URL (location.href)', function() {
@@ -30,5 +30,6 @@ describe('SCE URL policy when base tags are present', function() {
3030
browser.executeScript(
3131
'document.getElementsByTagName("base")[0].href = "http://xxx.example.com/";');
3232
checkUrl('http://xxx.example.com/path/to/file.html', true);
33+
checkUrl('http://www.example.com/path/to/file.html', false);
3334
});
3435
});

0 commit comments

Comments
 (0)