From f2b5889b6b4172d6bd32eb16ebf6444ff8af0bf7 Mon Sep 17 00:00:00 2001 From: Thomas Kaul <4159106+dtslvr@users.noreply.github.com> Date: Sat, 30 May 2026 09:27:28 +0200 Subject: [PATCH] Refactoring --- apps/api/src/services/fetch/fetch.service.ts | 21 ++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/apps/api/src/services/fetch/fetch.service.ts b/apps/api/src/services/fetch/fetch.service.ts index 7d074ee9b..53c06e9dc 100644 --- a/apps/api/src/services/fetch/fetch.service.ts +++ b/apps/api/src/services/fetch/fetch.service.ts @@ -40,7 +40,10 @@ export class FetchService implements OnModuleInit { const url = input instanceof Request ? input.url : input.toString(); const urlRedacted = this.redactUrl(url); - const matchedWebFetchDomain = this.getMatchingWebFetchDomain(url, method); + const matchedWebFetchDomain = this.getMatchingWebFetchDomain({ + method, + url + }); Logger.debug(`${method} ${urlRedacted}`, 'FetchService'); @@ -160,15 +163,17 @@ export class FetchService implements OnModuleInit { } } - private getMatchingWebFetchDomain( - rawUrl: string, - method: string - ): WebFetchDomain | undefined { + private getMatchingWebFetchDomain({ + method, + url + }: { + method: string; + url: string; + }) { try { - const { hostname } = new URL(rawUrl); + const { hostname } = new URL(url); - return this.webFetchDomains.find((webFetchDomain) => { - const { domain, methods } = webFetchDomain; + return this.webFetchDomains.find(({ domain, methods }) => { const matchesDomain = hostname === domain || hostname.endsWith(`.${domain}`);