From 844d1402bafccd8aceaacda2c1ebcd79e70cc731 Mon Sep 17 00:00:00 2001 From: Opliko Date: Thu, 25 Apr 2024 13:16:05 +0200 Subject: [PATCH] refactor: use URLSearchParams instead of multiple encodeURIComponent --- src/activitypub/helpers.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/activitypub/helpers.js b/src/activitypub/helpers.js index 071143fc32..4f85b777e9 100644 --- a/src/activitypub/helpers.js +++ b/src/activitypub/helpers.js @@ -47,13 +47,14 @@ Helpers.query = async (id) => { return webfingerCache.get(id); } - const protocol = isUri ? '' : 'acct:'; // if ID is an URI the protocol is already included + // only add acct: schema if id is not an URI already + const query = new URLSearchParams({ resource: `${isUri ? '' : 'acct:'}${id}` }); // Make a webfinger query to retrieve routing information let response; let body; try { - ({ response, body } = await request.get(`https://${hostname}/.well-known/webfinger?resource=${encodeURIComponent(protocol)}${encodeURIComponent(id)}`)); + ({ response, body } = await request.get(`https://${hostname}/.well-known/webfinger?${query}`)); } catch (e) { return false; }