From: Ardis Lu Date: Sat, 21 Jan 2023 22:01:51 +0000 (-0800) Subject: Decode HTML entities X-Git-Url: https://git.ardis.lu/?a=commitdiff_plain;h=74909b1b3d5f2c58eb9fc37374019be245c6638b;p=cloudflare-workers Decode HTML entities Workers runtime does not automatically do this for text --- diff --git a/buttcoin.png b/buttcoin.png index ab1f75a..15b8f82 100644 Binary files a/buttcoin.png and b/buttcoin.png differ diff --git a/buttcoin/index.js b/buttcoin/index.js index a1988ff..1699bbc 100644 --- a/buttcoin/index.js +++ b/buttcoin/index.js @@ -1,3 +1,5 @@ +import { decode } from 'html-entities'; + class SetBase { constructor(origin) { this.origin = origin; @@ -31,7 +33,7 @@ class ReplaceBitcoin { .replaceAll('Bitcoin', 'Buttcoin') .replaceAll('BITCOIN', 'BUTTCOIN') .replaceAll(/bitcoin/gi, 'buttcoin'); // Any other mixed case just become buttcoin - text.replace(buttText); + text.replace(decode(buttText)); this.#buffer = ''; } else { diff --git a/buttcoin/package.json b/buttcoin/package.json index ffe601f..aea4a76 100644 --- a/buttcoin/package.json +++ b/buttcoin/package.json @@ -9,6 +9,9 @@ "dev": "wrangler dev", "publish": "wrangler publish" }, + "dependencies": { + "html-entities": "^2.3.3" + }, "repository": { "type": "git", "url": "https://github.com/ardislu/cloudflare-workers.git" diff --git a/package-lock.json b/package-lock.json index d0e2c77..7e5a8f6 100644 --- a/package-lock.json +++ b/package-lock.json @@ -18,12 +18,20 @@ "uuid", "hash", "style", - "unroll" + "unroll", + "buttcoin" ], "devDependencies": { "wrangler": "^2.8.0" } }, + "buttcoin": { + "version": "0.2.0", + "license": "ISC", + "dependencies": { + "html-entities": "^2.3.3" + } + }, "cors": { "version": "0.2.0", "license": "ISC" @@ -442,6 +450,10 @@ "node": ">=10.16.0" } }, + "node_modules/buttcoin": { + "resolved": "buttcoin", + "link": true + }, "node_modules/camelcase": { "version": "5.3.1", "resolved": "https://registry.npmjs.org/camelcase/-/camelcase-5.3.1.tgz", @@ -1038,6 +1050,11 @@ "resolved": "hash", "link": true }, + "node_modules/html-entities": { + "version": "2.3.3", + "resolved": "https://registry.npmjs.org/html-entities/-/html-entities-2.3.3.tgz", + "integrity": "sha512-DV5Ln36z34NNTDgnz0EWGBLZENelNAtkiFA4kyNOG2tDI6Mz1uSWiq1wAKdyjnJwyDiDO7Fa2SO1CTxPXL8VxA==" + }, "node_modules/html-rewriter-wasm": { "version": "0.4.1", "resolved": "https://registry.npmjs.org/html-rewriter-wasm/-/html-rewriter-wasm-0.4.1.tgz", @@ -2237,6 +2254,12 @@ "streamsearch": "^1.1.0" } }, + "buttcoin": { + "version": "file:buttcoin", + "requires": { + "html-entities": "^2.3.3" + } + }, "camelcase": { "version": "5.3.1", "resolved": "https://registry.npmjs.org/camelcase/-/camelcase-5.3.1.tgz", @@ -2578,6 +2601,11 @@ "hash": { "version": "file:hash" }, + "html-entities": { + "version": "2.3.3", + "resolved": "https://registry.npmjs.org/html-entities/-/html-entities-2.3.3.tgz", + "integrity": "sha512-DV5Ln36z34NNTDgnz0EWGBLZENelNAtkiFA4kyNOG2tDI6Mz1uSWiq1wAKdyjnJwyDiDO7Fa2SO1CTxPXL8VxA==" + }, "html-rewriter-wasm": { "version": "0.4.1", "resolved": "https://registry.npmjs.org/html-rewriter-wasm/-/html-rewriter-wasm-0.4.1.tgz",