From 96d4255eb0bc9421b1e72d0450ec44700f8e9164 Mon Sep 17 00:00:00 2001 From: K Date: Sat, 10 Aug 2024 15:50:10 +0100 Subject: [PATCH] #2692 npub validation --- .../core/server/routes/core.server.routes.js | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/modules/core/server/routes/core.server.routes.js b/modules/core/server/routes/core.server.routes.js index 3847aa7394..73d707f75c 100644 --- a/modules/core/server/routes/core.server.routes.js +++ b/modules/core/server/routes/core.server.routes.js @@ -70,19 +70,17 @@ module.exports = function (app) { } else { const nostrNpub = user.nostrNpub; - if (nostrNpub) { + if (nostrNpub && nostrNpub.startsWith('npub1')) { var result = nip19.decode(nostrNpub); - var hex = result.data; + var obj = { + names: { + [name]: result.data, + }, + }; } else { - // what should we return if there's no npub? - var hex = 'no npub'; + var obj = {}; } - - res.json({ - names: { - [name]: hex, - }, - }); + res.json(obj); } }); });