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

Commit

Permalink
fix($browser): remove base href domain when url begins with '//'
Browse files Browse the repository at this point in the history
This change prevents an incorrect appBase url from being calculated when the
<base> href's domain begins with '//'.

Closes #5606
  • Loading branch information
caitp authored and IgorMinar committed Jan 3, 2014
1 parent c9705b7 commit 760f2fb
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/ng/browser.js
Original file line number Diff line number Diff line change
Expand Up @@ -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?\:)?\/\/[^\/]*/, '') : '';
};

//////////////////////////////////////////////////////////////
Expand Down
5 changes: 5 additions & 0 deletions test/ng/browserSpecs.js
Original file line number Diff line number Diff line change
Expand Up @@ -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/');
});
});
});

0 comments on commit 760f2fb

Please sign in to comment.