From fe838f80e31015f535b94a06fdedba88674d6b75 Mon Sep 17 00:00:00 2001 From: MattIPv4 Date: Sun, 9 Jan 2022 03:30:16 +0000 Subject: [PATCH] Decode HTML entities from Twitter --- package-lock.json | 11 +++++++++++ package.json | 1 + src/index.js | 3 ++- 3 files changed, 14 insertions(+), 1 deletion(-) diff --git a/package-lock.json b/package-lock.json index e4b83db..a4e1a0a 100644 --- a/package-lock.json +++ b/package-lock.json @@ -9,6 +9,7 @@ "version": "1.0.0", "license": "Apache-2.0", "dependencies": { + "html-entities": "^2.3.2", "workers-sentry": "^0.0.6" }, "devDependencies": { @@ -2195,6 +2196,11 @@ "minimalistic-crypto-utils": "^1.0.1" } }, + "node_modules/html-entities": { + "version": "2.3.2", + "resolved": "https://registry.npmjs.org/html-entities/-/html-entities-2.3.2.tgz", + "integrity": "sha512-c3Ab/url5ksaT0WyleslpBEthOzWhrjQbg75y7XUsfSzi3Dgzt0l8w5e7DylRn15MTlMMD58dTfzddNS2kcAjQ==" + }, "node_modules/https-browserify": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/https-browserify/-/https-browserify-1.0.0.tgz", @@ -6288,6 +6294,11 @@ "minimalistic-crypto-utils": "^1.0.1" } }, + "html-entities": { + "version": "2.3.2", + "resolved": "https://registry.npmjs.org/html-entities/-/html-entities-2.3.2.tgz", + "integrity": "sha512-c3Ab/url5ksaT0WyleslpBEthOzWhrjQbg75y7XUsfSzi3Dgzt0l8w5e7DylRn15MTlMMD58dTfzddNS2kcAjQ==" + }, "https-browserify": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/https-browserify/-/https-browserify-1.0.0.tgz", diff --git a/package.json b/package.json index 7af4659..df3fbfd 100644 --- a/package.json +++ b/package.json @@ -19,6 +19,7 @@ }, "homepage": "https://github.com/MattIPv4/tweets-to-discord#readme", "dependencies": { + "html-entities": "^2.3.2", "workers-sentry": "^0.0.6" }, "devDependencies": { diff --git a/src/index.js b/src/index.js index f11fa77..794c4b2 100644 --- a/src/index.js +++ b/src/index.js @@ -1,4 +1,5 @@ const WorkersSentry = require('workers-sentry/worker'); +const htmlEntities = require('html-entities'); // Util to send a text response const textResponse = content => new Response(content, { @@ -41,7 +42,7 @@ const postDiscordTweet = (type, content, links, username, avatar) => fetch(proce method: 'POST', headers: { 'Content-type': 'application/json' }, body: JSON.stringify({ - content: `**${type}**\n\n${quoteText(escapeMarkdown(content))}\n\n${suppressLinks(links)}`, + content: `**${type}**\n\n${quoteText(escapeMarkdown(htmlEntities.decode(content)))}\n\n${suppressLinks(links)}`, username, avatar_url: avatar, }),