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

fix($browser): .url() should always return self in setter mode #10157

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/ng/browser.js
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ function Browser(window, document, $log, $sniffer) {
// IE<10 from getting into redirect loop when in LocationHashbangInHtml5Url mode.
// See https://github.com/angular/angular.js/commit/ffb2701
if (lastBrowserUrl === url && (!$sniffer.history || sameState)) {
return;
return self;
}
var sameBase = lastBrowserUrl && stripHash(lastBrowserUrl) === stripHash(url);
lastBrowserUrl = url;
Expand Down
6 changes: 6 additions & 0 deletions test/ng/browserSpecs.js
Original file line number Diff line number Diff line change
Expand Up @@ -576,6 +576,12 @@ describe('browser', function() {
expect(browser.url('http://any.com')).toBe(browser);
});

it('should return $browser to allow chaining even if the previous and current URLs and states match', function() {
expect(browser.url('http://any.com').url('http://any.com')).toBe(browser);
var state = { any: 'foo' };
expect(browser.url('http://any.com', false, state).url('http://any.com', false, state)).toBe(browser);
expect(browser.url('http://any.com', true, state).url('http://any.com', true, state)).toBe(browser);
});

it('should decode single quotes to work around FF bug 407273', function() {
fakeWindow.location.href = "http://ff-bug/?single%27quote";
Expand Down