diff --git a/src/ng/browser.js b/src/ng/browser.js index 68e8ba9383ee..3bb51b57606d 100644 --- a/src/ng/browser.js +++ b/src/ng/browser.js @@ -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?\:)?\/\/[^\/]*/, '') : ''; }; ////////////////////////////////////////////////////////////// diff --git a/test/ng/browserSpecs.js b/test/ng/browserSpecs.js index 6c6ac30e2195..4157ecbdb7fd 100755 --- a/test/ng/browserSpecs.js +++ b/test/ng/browserSpecs.js @@ -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 beginning with \'//\'', function() { + fakeDocument.basePath = '//google.com/base/path/'; + expect(browser.baseHref()).toEqual('/base/path/'); + }); }); });