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:
Caitlin Potter 2014-01-02 19:12:31 -05:00 committed by Igor Minar
parent c9705b7556
commit 760f2fb731
2 changed files with 6 additions and 1 deletions

View file

@ -253,7 +253,7 @@ function Browser(window, document, $log, $sniffer) {
*/
self.baseHref = function() {
var href = baseElement.attr('href');
return href ? href.replace(/^https?\:\/\/[^\/]*/, '') : '';
return href ? href.replace(/^(https?\:)?\/\/[^\/]*/, '') : '';
};
//////////////////////////////////////////////////////////////

View file

@ -609,5 +609,10 @@ describe('browser', function() {
fakeDocument.basePath = 'http://host.com/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/');
});
});
});