diff --git a/src/ng/browser.js b/src/ng/browser.js index 864c972c8c77..3925348317ce 100644 --- a/src/ng/browser.js +++ b/src/ng/browser.js @@ -149,6 +149,7 @@ function Browser(window, document, $log, $sniffer) { self.url = function(url, replace) { // setter if (url) { + if (lastBrowserUrl == url) return; lastBrowserUrl = url; if ($sniffer.history) { if (replace) history.replaceState(null, '', url); diff --git a/test/ng/browserSpecs.js b/test/ng/browserSpecs.js index 55b8167ce12e..3f28c6059c5c 100644 --- a/test/ng/browserSpecs.js +++ b/test/ng/browserSpecs.js @@ -468,6 +468,14 @@ describe('browser', function() { fakeWindow.location.href = "http://ff-bug/?single%27quote"; expect(browser.url()).toBe("http://ff-bug/?single'quote"); }); + + it('should not set URL when the URL is already set', function() { + var current = fakeWindow.location.href; + sniffer.history = false; + fakeWindow.location.href = 'dontchange'; + browser.url(current); + expect(fakeWindow.location.href).toBe('dontchange'); + }); }); describe('urlChange', function() {