Browse Source

Refactoring

pull/6960/head
Thomas Kaul 3 months ago
parent
commit
f2b5889b6b
  1. 21
      apps/api/src/services/fetch/fetch.service.ts

21
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}`);

Loading…
Cancel
Save