diff options
| author | Caitlin Potter | 2014-01-02 19:12:31 -0500 | 
|---|---|---|
| committer | Igor Minar | 2014-01-02 16:36:31 -0800 | 
| commit | 760f2fb73178e56c37397b3c5876f7dac96f0455 (patch) | |
| tree | 83927e139f2d3248b07d6a2eb62c53d2696b0713 | |
| parent | c9705b755645a4bfe066243f2ba15a733c3787e1 (diff) | |
| download | angular.js-760f2fb73178e56c37397b3c5876f7dac96f0455.tar.bz2 | |
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
| -rw-r--r-- | src/ng/browser.js | 2 | ||||
| -rwxr-xr-x | test/ng/browserSpecs.js | 5 | 
2 files changed, 6 insertions, 1 deletions
| diff --git a/src/ng/browser.js b/src/ng/browser.js index 68e8ba93..3bb51b57 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 6c6ac30e..4157ecbd 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 <base href> beginning with \'//\'', function() { +      fakeDocument.basePath = '//google.com/base/path/'; +      expect(browser.baseHref()).toEqual('/base/path/'); +    });    });  }); | 
