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 url = input instanceof Request ? input.url : input.toString();
const urlRedacted = this.redactUrl(url); const urlRedacted = this.redactUrl(url);
const matchedWebFetchDomain = this.getMatchingWebFetchDomain(url, method); const matchedWebFetchDomain = this.getMatchingWebFetchDomain({
method,
url
});
Logger.debug(`${method} ${urlRedacted}`, 'FetchService'); Logger.debug(`${method} ${urlRedacted}`, 'FetchService');
@ -160,15 +163,17 @@ export class FetchService implements OnModuleInit {
} }
} }
private getMatchingWebFetchDomain( private getMatchingWebFetchDomain({
rawUrl: string, method,
method: string url
): WebFetchDomain | undefined { }: {
method: string;
url: string;
}) {
try { try {
const { hostname } = new URL(rawUrl); const { hostname } = new URL(url);
return this.webFetchDomains.find((webFetchDomain) => { return this.webFetchDomains.find(({ domain, methods }) => {
const { domain, methods } = webFetchDomain;
const matchesDomain = const matchesDomain =
hostname === domain || hostname.endsWith(`.${domain}`); hostname === domain || hostname.endsWith(`.${domain}`);

Loading…
Cancel
Save