mirror of
https://github.com/NodeBB/NodeBB.git
synced 2026-02-28 01:21:13 +01:00
refactor: use URLSearchParams instead of multiple encodeURIComponent
This commit is contained in:
@@ -47,13 +47,14 @@ Helpers.query = async (id) => {
|
|||||||
return webfingerCache.get(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
|
// Make a webfinger query to retrieve routing information
|
||||||
let response;
|
let response;
|
||||||
let body;
|
let body;
|
||||||
try {
|
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) {
|
} catch (e) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user