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

Commit 294d679

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 cefcc46 commit 294d679

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
@@ -2537,6 +2537,18 @@ describe('$location', function() {
25372537
it('should throw on url(urlString, stateObject)', function() {
25382538
expectThrowOnStateChange(locationUrl);
25392539
});
2540+
2541+
it('should not throw when base path is another domain', function() {
2542+
initService({html5Mode: true, hashPrefix: '!', supportHistory: true});
2543+
inject(
2544+
initBrowser({url: 'http://domain.com/base/', basePath: 'http://otherdomain.com/base/'}),
2545+
function($location) {
2546+
expect(function() {
2547+
$location.absUrl();
2548+
}).not.toThrow();
2549+
}
2550+
);
2551+
});
25402552
});
25412553

25422554

0 commit comments

Comments
 (0)