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

Commit b9ac336

Browse files
Guillaume Sallesgkalpak
Guillaume Salles
authored andcommitted
fix($location) : initialize $$absUrl to empty string
Initialize `$$absUrl` to an empty string, in order to avoid exception, when base href and current location have different domains. Fixes #11091 Fixes #13565 Closes #14488
1 parent 4ee5717 commit b9ac336

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-0
lines changed

src/ng/location.js

+6
Original file line numberDiff line numberDiff line change
@@ -328,6 +328,12 @@ function LocationHashbangInHtml5Url(appBase, appBaseNoFile, hashPrefix) {
328328

329329
var locationPrototype = {
330330

331+
/**
332+
* Ensure absolute url is initialized.
333+
* @private
334+
*/
335+
$$absUrl:'',
336+
331337
/**
332338
* Are we in html5 mode?
333339
* @private

test/ng/locationSpec.js

+12
Original file line numberDiff line numberDiff line change
@@ -2559,6 +2559,18 @@ describe('$location', function() {
25592559
it('should throw on url(urlString, stateObject)', function() {
25602560
expectThrowOnStateChange(locationUrl);
25612561
});
2562+
2563+
it('should not throw when base path is another domain', function() {
2564+
initService({html5Mode: true, hashPrefix: '!', supportHistory: true});
2565+
inject(
2566+
initBrowser({url: 'http://domain.com/base/', basePath: 'http://otherdomain.com/base/'}),
2567+
function($location) {
2568+
expect(function() {
2569+
$location.absUrl();
2570+
}).not.toThrow();
2571+
}
2572+
);
2573+
});
25622574
});
25632575

25642576

0 commit comments

Comments
 (0)