Fix hashing
continuous-integration/drone/push Build is passing Details

This commit is contained in:
DutchEllie 2022-07-13 18:11:21 +02:00
parent 75f3777b46
commit 1038602d5b
Signed by: DutchEllie
SSH Key Fingerprint: SHA256:dKq6ZSgN5E3Viqrw/+xAdf2VdR6hdRGNyrYqXXwfjTY
1 changed files with 7 additions and 2 deletions

View File

@ -32,6 +32,11 @@
let DisplayComments: Comment[]; let DisplayComments: Comment[];
let commentPage = 0; let commentPage = 0;
let pageSize = 10; let pageSize = 10;
const escapeHtml = (unsafe) => {
return unsafe.replaceAll('&', '&amp;').replaceAll('<', '&lt;').replaceAll('>', '&gt;').replaceAll('"', '&quot;').replaceAll("'", '&#039;');
}
async function onSubmit(event: SubmitEvent) { async function onSubmit(event: SubmitEvent) {
// Validation // Validation
if (name === '' || message === '') { if (name === '' || message === '') {
@ -86,7 +91,7 @@
// Check if in localstorage already // Check if in localstorage already
let commentLS = localStorage.getItem('comments'); let commentLS = localStorage.getItem('comments');
let comments: Comment[]; let comments: Comment[];
if (commentLS === null) { if (commentLS == null) {
// Not yet in storage // Not yet in storage
comments = await updateComments(); comments = await updateComments();
DisplayComments = comments; DisplayComments = comments;
@ -99,7 +104,7 @@
return t; return t;
}); });
let oldHash = localStorage.getItem('commenthash'); let oldHash = localStorage.getItem('commenthash');
if (oldHash != newHash) { if (oldHash?.trim() !== newHash.trim()) {
DisplayComments = await updateComments(); DisplayComments = await updateComments();
return; return;
} }