Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed updating URL with uri-decoded value #4026

Merged
merged 1 commit into from
May 6, 2016
Merged
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
11 changes: 7 additions & 4 deletions backbone.js
Original file line number Diff line number Diff line change
Expand Up @@ -1814,11 +1814,14 @@
}
var url = rootPath + fragment;

// Strip the hash and decode for matching.
fragment = this.decodeFragment(fragment.replace(pathStripper, ''));
// Strip the fragment of the query and hash for matching.
fragment = fragment.replace(pathStripper, '');

if (this.fragment === fragment) return;
this.fragment = fragment;
// Decode for matching.
var decodedFragment = this.decodeFragment(fragment);

if (this.fragment === decodedFragment) return;
this.fragment = decodedFragment;

// If pushState is available, we use it to set the fragment as a real URL.
if (this._usePushState) {
Expand Down
7 changes: 7 additions & 0 deletions test/router.js
Original file line number Diff line number Diff line change
Expand Up @@ -1059,4 +1059,11 @@
Backbone.history.start({root: '®ooτ', pushState: true});
});

QUnit.test('#4025 - navigate updates URL hash as is', function(assert) {
assert.expect(1);
var route = 'search/has%20space';
Backbone.history.navigate(route);
assert.strictEqual(location.hash, '#' + route);
});

})();