diff --git a/js/parseMessage.js b/js/parseMessage.js index 0aaa2be4..f24ff45a 100644 --- a/js/parseMessage.js +++ b/js/parseMessage.js @@ -3,7 +3,7 @@ let parseMessage = (text, embed = false) => { let textContent = text.replace(/(<)([^>]+)(>)/gm, '<$2>'); // General message parsing - textContent = textContent.replace(/ /g, ' '); + textContent = textContent.replace(/ /g, ' NBSP_PLACEHOLDER '); textContent = textContent.replace(/https?:\/\/[^ ]+(\.[^ ]+)+(\/[^ ]*)?/g, '$&'); // Add html tags for markup @@ -29,6 +29,9 @@ let parseMessage = (text, embed = false) => { if (!textContent.replace(/(\u00a9|\u00ae|[\u2000-\u3300]|\ud83c[\ud000-\udfff]|\ud83d[\ud000-\udfff]|\ud83e[\ud000-\udfff])/g, "").length) { textContent = `${textContent}` } + + // Replace the placeholder with a real nbsp + textContent = textContent.replace(/ NBSP_PLACEHOLDER /g, ' '); // Parse the emojis to SVGs textContent = twemoji.parse(textContent);