mirror of
https://github.com/Hopiu/angular.js.git
synced 2026-05-22 13:21:51 +00:00
fix($browser): remove base href domain when url begins with '//'
This change prevents an incorrect appBase url from being calculated when the <base> href's domain begins with '//'. Closes #5606
This commit is contained in:
parent
c9705b7556
commit
760f2fb731
2 changed files with 6 additions and 1 deletions
|
|
@ -253,7 +253,7 @@ function Browser(window, document, $log, $sniffer) {
|
||||||
*/
|
*/
|
||||||
self.baseHref = function() {
|
self.baseHref = function() {
|
||||||
var href = baseElement.attr('href');
|
var href = baseElement.attr('href');
|
||||||
return href ? href.replace(/^https?\:\/\/[^\/]*/, '') : '';
|
return href ? href.replace(/^(https?\:)?\/\/[^\/]*/, '') : '';
|
||||||
};
|
};
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////
|
||||||
|
|
|
||||||
|
|
@ -609,5 +609,10 @@ describe('browser', function() {
|
||||||
fakeDocument.basePath = 'http://host.com/base/path/index.html';
|
fakeDocument.basePath = 'http://host.com/base/path/index.html';
|
||||||
expect(browser.baseHref()).toEqual('/base/path/index.html');
|
expect(browser.baseHref()).toEqual('/base/path/index.html');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('should remove domain from <base href> beginning with \'//\'', function() {
|
||||||
|
fakeDocument.basePath = '//google.com/base/path/';
|
||||||
|
expect(browser.baseHref()).toEqual('/base/path/');
|
||||||
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue