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
This commit is contained in:
Guillaume Salles
2016-04-21 17:30:34 -04:00
committed by Georgios Kalpakas
parent 4ee5717a96
commit b9ac3362ee
2 changed files with 18 additions and 0 deletions
+6
View File
@@ -328,6 +328,12 @@ function LocationHashbangInHtml5Url(appBase, appBaseNoFile, hashPrefix) {
var locationPrototype = {
/**
* Ensure absolute url is initialized.
* @private
*/
$$absUrl:'',
/**
* Are we in html5 mode?
* @private
+12
View File
@@ -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();
}
);
});
});