From 88cfd005fd8ca72e4e2328dc3405290ff5e29866 Mon Sep 17 00:00:00 2001 From: Jesse Wierzbinski Date: Wed, 17 Jul 2024 14:36:49 +0200 Subject: [PATCH] feat(federation): :sparkles: Allow specifying custom hostname in WebFinger requests --- federation/requester/index.ts | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/federation/requester/index.ts b/federation/requester/index.ts index a0119a0..886b9b8 100644 --- a/federation/requester/index.ts +++ b/federation/requester/index.ts @@ -71,6 +71,7 @@ export class FederationRequester { /** * Get the user's profile link from their username. * @param username The username to get the profile link for. + * @param hostname The hostname to get the profile link for (defaults to the server's hostname). * @returns The user's profile link. * @throws If the request fails or the response is invalid. * @example @@ -79,10 +80,13 @@ export class FederationRequester { * console.log(profileLink); * // => "https://example.com/users/1" */ - public async webFinger(username: string): Promise { + public async webFinger( + username: string, + hostname = this.serverUrl.hostname, + ): Promise { const result = await this.get( `/.well-known/webfinger?${new URLSearchParams({ - resource: `acct:${username}@${this.serverUrl.hostname}`, + resource: `acct:${username}@${hostname}`, })}`, );