Skip to content

Commit 84f5ec4

Browse files
committed
PR feedback
1 parent d126e00 commit 84f5ec4

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

packages/utils/src/instrument.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -227,9 +227,10 @@ export function parseFetchArgs(fetchArgs: unknown[]): { method: string; url: str
227227
};
228228
}
229229

230+
const arg = fetchArgs[0];
230231
return {
231-
url: getUrlFromResource(fetchArgs[0] as FetchResource),
232-
method: 'GET',
232+
url: getUrlFromResource(arg as FetchResource),
233+
method: hasProp(arg, 'method') ? String(arg.method).toUpperCase() : 'GET',
233234
};
234235
}
235236

packages/utils/test/instrument.test.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,11 @@ describe('instrument', () => {
66
['string URL only', ['http://example.com'], { method: 'GET', url: 'http://example.com' }],
77
['URL object only', [new URL('http://example.com')], { method: 'GET', url: 'http://example.com/' }],
88
['Request URL only', [{ url: 'http://example.com' }], { method: 'GET', url: 'http://example.com' }],
9+
[
10+
'Request URL & method only',
11+
[{ url: 'http://example.com', method: 'post' }],
12+
{ method: 'POST', url: 'http://example.com' },
13+
],
914
[
1015
'string URL & options',
1116
['http://example.com', { method: 'post' }],

0 commit comments

Comments
 (0)