Skip to content

Commit

Permalink
Chore: refactor code and use @kylesands’ version
Browse files Browse the repository at this point in the history
  • Loading branch information
GwynethLlewelyn committed Apr 21, 2024
1 parent c8692e9 commit 0792206
Showing 1 changed file with 11 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,17 @@
// Firefox seems to have an odd bug which affects clicking backspace in quick succession.
// Kudos to @gvp9000 and for the fix below. (gwyneth 20240414)
// @see https://www.phpbb.com/customise/db/extension/postlocalstorage/support/topic/246616?p=877489#p877489
var count_hash_num = key.split("#").length - 1;
for (let i = 0; i < count_hash_num; i++) {
key = key.substring(0, key.lastIndexOf('#'));
// @kylesands has suggested a diferent method, one that deals better with other situations, e.g. when the
// `sid` is passed via URL, which happens every once in a while: (gwyneth 20240421)
if (key.includes("/posting.php")) { // Posting
if (key.endsWith("#preview")) {
key = key.slice(0, -8); // It keeps the key the same when previewing or not to help with recovery
}
if (key.includes("&sid=")) {
key = key.split("&sid=")[0];
}
} else if (key.includes("/ucp.php")) { // PM'ing
key = key.split("?")[0]; // It keeps the key the same when previewing or not to help with recovery
}
/**
* JSON object to be saved with the textarea content + subject content + timestamp.
Expand Down

0 comments on commit 0792206

Please sign in to comment.