Skip to content

Commit 4669dc5

Browse files
committed
fix: use url parsing util instead
1 parent 08fdba6 commit 4669dc5

File tree

1 file changed

+2
-7
lines changed

1 file changed

+2
-7
lines changed

packages/nitro/src/runtime/hooks/captureErrorHook.ts

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import {
55
getClient,
66
getCurrentScope,
77
getRootSpan,
8+
parseUrl,
89
SEMANTIC_ATTRIBUTE_SENTRY_SOURCE,
910
} from '@sentry/core';
1011
import { HTTPError } from 'h3';
@@ -23,13 +24,7 @@ function extractErrorContext(errorContext: CapturedErrorContext | undefined): Re
2324

2425
if (errorContext.event) {
2526
ctx.method = errorContext.event.req.method;
26-
27-
try {
28-
const url = new URL(errorContext.event.req.url);
29-
ctx.path = url.pathname;
30-
} catch {
31-
// If URL parsing fails, leave path undefined
32-
}
27+
ctx.path = parseUrl(errorContext.event.req.url).path;
3328
}
3429

3530
if (Array.isArray(errorContext.tags)) {

0 commit comments

Comments
 (0)