Skip to content

Commit

Permalink
PR feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
mydea committed Apr 3, 2023
1 parent d126e00 commit 84f5ec4
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
5 changes: 3 additions & 2 deletions packages/utils/src/instrument.ts
Original file line number Diff line number Diff line change
Expand Up @@ -227,9 +227,10 @@ export function parseFetchArgs(fetchArgs: unknown[]): { method: string; url: str
};
}

const arg = fetchArgs[0];
return {
url: getUrlFromResource(fetchArgs[0] as FetchResource),
method: 'GET',
url: getUrlFromResource(arg as FetchResource),
method: hasProp(arg, 'method') ? String(arg.method).toUpperCase() : 'GET',
};
}

Expand Down
5 changes: 5 additions & 0 deletions packages/utils/test/instrument.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@ describe('instrument', () => {
['string URL only', ['http://example.com'], { method: 'GET', url: 'http://example.com' }],
['URL object only', [new URL('http://example.com')], { method: 'GET', url: 'http://example.com/' }],
['Request URL only', [{ url: 'http://example.com' }], { method: 'GET', url: 'http://example.com' }],
[
'Request URL & method only',
[{ url: 'http://example.com', method: 'post' }],
{ method: 'POST', url: 'http://example.com' },
],
[
'string URL & options',
['http://example.com', { method: 'post' }],
Expand Down

0 comments on commit 84f5ec4

Please sign in to comment.