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

Commit

Permalink
fix($location) : initialize $$absUrl to empty string
Browse files Browse the repository at this point in the history
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
  • Loading branch information
Guillaume Salles authored and gkalpak committed Jun 6, 2016
1 parent 4ee5717 commit b9ac336
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/ng/location.js
Original file line number Diff line number Diff line change
Expand Up @@ -328,6 +328,12 @@ function LocationHashbangInHtml5Url(appBase, appBaseNoFile, hashPrefix) {

var locationPrototype = {

/**
* Ensure absolute url is initialized.
* @private
*/
$$absUrl:'',

/**
* Are we in html5 mode?
* @private
Expand Down
12 changes: 12 additions & 0 deletions test/ng/locationSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -2559,6 +2559,18 @@ describe('$location', function() {
it('should throw on url(urlString, stateObject)', function() {
expectThrowOnStateChange(locationUrl);
});

it('should not throw when base path is another domain', function() {
initService({html5Mode: true, hashPrefix: '!', supportHistory: true});
inject(
initBrowser({url: 'http://domain.com/base/', basePath: 'http://otherdomain.com/base/'}),
function($location) {
expect(function() {
$location.absUrl();
}).not.toThrow();
}
);
});
});


Expand Down

0 comments on commit b9ac336

Please sign in to comment.