Merge pull request #4026 from Flamefork/4025-encoded-fragment

Fixed updating URL with uri-decoded value
This commit is contained in:
Justin Ridgewell
2016-05-06 13:03:00 -04:00
2 changed files with 14 additions and 4 deletions

View File

@@ -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) {

View File

@@ -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);
});
})();