mirror of
https://github.com/jashkenas/backbone.git
synced 2026-04-30 03:00:06 -04:00
Merge pull request #4026 from Flamefork/4025-encoded-fragment
Fixed updating URL with uri-decoded value
This commit is contained in:
11
backbone.js
11
backbone.js
@@ -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) {
|
||||
|
||||
@@ -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);
|
||||
});
|
||||
|
||||
})();
|
||||
|
||||
Reference in New Issue
Block a user