mirror of
https://github.com/Jermolene/TiddlyWiki5
synced 2024-11-30 05:19:57 +00:00
Fix bug when location hash contains a # (#4947)
The bug fixed in this commit had an interesting side effect when the location hash started with #, e.g. it looked like wiki.html##foo. In that case, TiddlyWiki's navigation processing is not triggered and the browser's navigation processing is used instead, which allows anchors to be used within tiddlers for sub-tiddler navigation. To preserve this unintended but useful side-effect, we check for a location hash that starts with # and ignore it if it does.
This commit is contained in:
parent
c6cd4d33e6
commit
ecb3c86e7b
12
boot/boot.js
12
boot/boot.js
@ -267,8 +267,16 @@ $tw.utils.htmlDecode = function(s) {
|
|||||||
Get the browser location.hash. We don't use location.hash because of the way that Firefox auto-urldecodes it (see http://stackoverflow.com/questions/1703552/encoding-of-window-location-hash)
|
Get the browser location.hash. We don't use location.hash because of the way that Firefox auto-urldecodes it (see http://stackoverflow.com/questions/1703552/encoding-of-window-location-hash)
|
||||||
*/
|
*/
|
||||||
$tw.utils.getLocationHash = function() {
|
$tw.utils.getLocationHash = function() {
|
||||||
var parts = window.location.href.split('#');
|
var href = window.location.href;
|
||||||
return "#" + (parts.length > 1 ? parts[1] : "");
|
var idx = href.indexOf('#');
|
||||||
|
if(idx === -1) {
|
||||||
|
return "#";
|
||||||
|
} else if(idx < href.length-1 && href[idx+1] === '#') {
|
||||||
|
// Special case: ignore location hash if it itself starts with a #
|
||||||
|
return "#";
|
||||||
|
} else {
|
||||||
|
return href.substring(idx);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
Loading…
Reference in New Issue
Block a user