Share plugin: decode the URI component before checking for the leading hash sign

Should compensate for the mangling we get from Discourse – see https://talk.tiddlywiki.org/t/revived-share-plugin/5887
This commit is contained in:
jeremy@jermolene.com 2023-01-15 18:55:36 +00:00
parent 02d28c100b
commit c39ef398bf
1 changed files with 7 additions and 9 deletions

View File

@ -13,19 +13,17 @@ Read tiddlers from the browser location hash
"use strict";
// Get the hash
var rawHash = document.location.hash.substring(1);
if(rawHash.charAt(0) === "#") {
var hash;
try{
hash = decodeURIComponent(rawHash.substring(1));
} catch(ex) {
console.log("Share plugin: Error decoding location hash",ex);
}
var hash;
try {
hash = decodeURIComponent(document.location.hash.substring(1));
} catch(e) {
}
if(hash && hash.charAt(0) === "#") {
// Try to parse the hash as JSON
if(hash) {
var tiddlers;
try {
tiddlers= JSON.parse(hash);
tiddlers= JSON.parse(hash.substr(1));
} catch(ex) {
console.log("Share plugin: Error parsing JSON from location hash",ex);
}