mirror of
https://github.com/TiddlyWiki/TiddlyWiki5.git
synced 2026-02-01 22:07:41 +00:00
Reverts change to getLocationHash utils method (#9622)
* fix: reverted change to getLocationHash utils method * docs: update changenote
This commit is contained in:
21
boot/boot.js
21
boot/boot.js
@@ -316,8 +316,25 @@ $tw.utils.htmlDecode = function(s) {
|
||||
return s.toString().replace(/</mg,"<").replace(/ /mg,"\xA0").replace(/>/mg,">").replace(/"/mg,"\"").replace(/&/mg,"&");
|
||||
};
|
||||
|
||||
/** @deprecated Use window.location.hash instead. */
|
||||
$tw.utils.getLocationHash = () => 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() {
|
||||
const href = window.location.href,
|
||||
idx = href.indexOf("#");
|
||||
|
||||
if(idx === -1) {
|
||||
return "#";
|
||||
}
|
||||
|
||||
const afterHash = href.substring(idx + 1);
|
||||
if(afterHash.startsWith("#") || afterHash.startsWith("%23")) {
|
||||
// Special case: ignore location hash if it itself starts with a #
|
||||
return "#";
|
||||
}
|
||||
return href.substring(idx);
|
||||
};
|
||||
|
||||
|
||||
/** @deprecated Pad a string to a given length with "0"s. Length defaults to 2 */
|
||||
$tw.utils.pad = function(value,length = 2) {
|
||||
|
||||
@@ -4,7 +4,7 @@ release: 5.4.0
|
||||
tags: $:/tags/ChangeNote
|
||||
change-type: deprecation
|
||||
change-category: developer
|
||||
github-links: https://github.com/TiddlyWiki/TiddlyWiki5/pull/9251
|
||||
github-contributors: Leilei332
|
||||
github-links: https://github.com/TiddlyWiki/TiddlyWiki5/pull/9251 https://github.com/TiddlyWiki/TiddlyWiki5/pull/9622
|
||||
github-contributors: Leilei332 saqimtiaz
|
||||
|
||||
Deprecate some utility functions. Some of them are moved to [[$:/core/modules/utils/deprecated.js]].
|
||||
Reference in New Issue
Block a user