From f699c0739d09feb8960b2f5255e9998843682f6f Mon Sep 17 00:00:00 2001 From: Adam Soltys Date: Wed, 12 Mar 2025 11:41:36 -0700 Subject: handle peanuts --- src/lib/parse.ts | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'src/lib/parse.ts') diff --git a/src/lib/parse.ts b/src/lib/parse.ts index 949b38db..ba264be7 100644 --- a/src/lib/parse.ts +++ b/src/lib/parse.ts @@ -70,6 +70,27 @@ export default async (s, host) => { } } + if (t.match(/^🥜([\uFE00-\uFE0F]|[\uE0100-\uE01EF]+)$/)) { + t = Array.from(t) + .slice(1) + .map((char) => { + const codePoint = char.codePointAt(0); + + // Handle Variation Selectors (VS1-VS16): U+FE00 to U+FE0F + if (codePoint >= 0xfe00 && codePoint <= 0xfe0f) { + const byteValue = codePoint - 0xfe00; // Maps FE00->0, FE01->1, ..., FE0F->15 + return String.fromCharCode(byteValue); + } + + // Handle Variation Selectors Supplement (VS17-VS256): U+E0100 to U+E01EF + if (codePoint >= 0xe0100 && codePoint <= 0xe01ef) { + const byteValue = codePoint - 0xe0100 + 16; // Maps E0100->16, E0101->17, ..., E01EF->255 + return String.fromCharCode(byteValue); + } + }) + .join(""); + } + if (t.startsWith("cashu")) { const { id } = await post("/cash", { token: t }); redirect(307, `/ecash/${id}`); -- cgit v1.2.3