From 0a3fd0811428bb4dcb306a11e7bb1fd647948f50 Mon Sep 17 00:00:00 2001 From: Alexander Borsuk <me@alex.bio> Date: Thu, 9 Nov 2023 06:25:28 +0100 Subject: [PATCH] Fixed undefined titles in ru Signed-off-by: Alexander Borsuk <me@alex.bio> --- README.md | 2 +- src/ge0.ts | 7 +++---- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 511f565..cecbd09 100644 --- a/README.md +++ b/README.md @@ -30,7 +30,7 @@ npm i ## Development -Use `npx wrangler dev` for development using Cloudflare, or `npx wrangler dev --local` for localhost development. +Use `npx wrangler dev` for localhost development. ## Deployment diff --git a/src/ge0.ts b/src/ge0.ts index 375032e..27a8543 100644 --- a/src/ge0.ts +++ b/src/ge0.ts @@ -56,7 +56,7 @@ function normalizeZoom(zoom: string): number { } const htmlEntityCode = { - ' ': ' ', + ' ': ' ', '¢': '¢', '£': '£', '¥': '¥', @@ -71,7 +71,7 @@ const htmlEntityCode = { }; function encodeHTML(str: string) { - return str.replace(/[\u00A0-\u9999<>\&''""]/gm, (i) => htmlEntityCode[i]); + return str.replace(/[ ¢£¥€©®<>\&'"]/gm, (i) => htmlEntityCode[i]); } // Coordinates and zoom are validated separately. @@ -104,8 +104,7 @@ export async function onGe0Decode(template: string, url: string): Promise<Respon const llz = decodeLatLonZoom(encodedLatLonZoom); let [name, title] = normalizeNameAndTitle(params.length > 1 ? params[1] : undefined); // XSS prevention. - if (name != kSharedViaOM) - name = encodeHTML(name); + if (name != kSharedViaOM) name = encodeHTML(name); title = encodeHTML(title); template = replaceInTemplate(template, {