Title: Deprecate and remove `parseUrl` and refactor `getSanitizedUrlString` · Issue #15767 · getsentry/sentry-javascript · GitHub
Open Graph Title: Deprecate and remove `parseUrl` and refactor `getSanitizedUrlString` · Issue #15767 · getsentry/sentry-javascript
X Title: Deprecate and remove `parseUrl` and refactor `getSanitizedUrlString` · Issue #15767 · getsentry/sentry-javascript
Description: Description Now that we support ES2020 (aka not IE11 anymore) and Node.js 18+, we can get rid of parseUrl in favor of a method that just uses the built-in URL object. This will save us some bundle size (given we can remove that regex), a...
Open Graph Description: Description Now that we support ES2020 (aka not IE11 anymore) and Node.js 18+, we can get rid of parseUrl in favor of a method that just uses the built-in URL object. This will save us some bundle ...
X Description: Description Now that we support ES2020 (aka not IE11 anymore) and Node.js 18+, we can get rid of parseUrl in favor of a method that just uses the built-in URL object. This will save us some bundle ...
Opengraph URL: https://github.com/getsentry/sentry-javascript/issues/15767
X: @github
Domain: github.com
IPv4 address: 140.82.114.4
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Deprecate and remove `parseUrl` and refactor `getSanitizedUrlString`","articleBody":"### Description\n\nNow that we support ES2020 (aka not IE11 anymore) and Node.js 18+, we can get rid of `parseUrl` in favor of a method that just uses the built-in URL object. This will save us some bundle size (given we can remove that regex), and we get performance benefits from using native code.\n\nhttps://github.com/getsentry/sentry-javascript/blob/3d63621714b31c1ea4c2ab2d90d5684a36805a43/packages/core/src/utils-hoist/url.ts#L17\n\nInstead of just blanket replacing `parseUrl`, we'll slowly convert all it's usages to using a new helper, which looks something like so:\n\n```js\n/**\n * Parses string to a URL object\n *\n * @param url - The URL to parse\n * @returns The parsed URL object or undefined if the URL is invalid\n */\nexport function parseStringToURL(url: string): URL | undefined {\n try {\n // Node 20+, Chrome 120+, Firefox 115+, Safari 17+\n if ('canParse' in URL) {\n // Use `canParse` to short-circuit the URL constructor if it's not a valid URL\n // This is faster than trying to construct the URL and catching the error\n return (URL as unknown as URLwithCanParse).canParse(url) ? new URL(url) : undefined;\n }\n } catch {\n // empty body\n }\n\n return undefined;\n}\n```\n\n- [x] Remove all usages in `@sentry/core`, and implement `parseStringToURL`\n- [x] Replace https://github.com/getsentry/sentry-javascript/blob/3d63621714b31c1ea4c2ab2d90d5684a36805a43/packages/browser-utils/src/instrument/xhr.ts#L150\n- [ ] https://github.com/getsentry/sentry-javascript/blob/3d63621714b31c1ea4c2ab2d90d5684a36805a43/packages/browser/src/integrations/breadcrumbs.ts#L36\n- [ ] https://github.com/getsentry/sentry-javascript/blob/3d63621714b31c1ea4c2ab2d90d5684a36805a43/packages/opentelemetry/src/utils/parseSpanDescription.ts#L23\n- [ ] https://github.com/getsentry/sentry-javascript/blob/3d63621714b31c1ea4c2ab2d90d5684a36805a43/packages/node/src/integrations/http/SentryHttpInstrumentation.ts#L17\n- [ ] https://github.com/getsentry/sentry-javascript/blob/3d63621714b31c1ea4c2ab2d90d5684a36805a43/packages/node/src/integrations/node-fetch/SentryNodeFetchInstrumentation.ts#L6\n- [ ] https://github.com/getsentry/sentry-javascript/blob/3d63621714b31c1ea4c2ab2d90d5684a36805a43/packages/browser/src/tracing/request.ts#L22\n- [ ] https://github.com/getsentry/sentry-javascript/blob/3d63621714b31c1ea4c2ab2d90d5684a36805a43/packages/browser-utils/src/metrics/browserMetrics.ts#L9\n\nWith that, we can also refactor `getSanitizedUrlString`, which should provide some performance benefits.\n\nhttps://github.com/getsentry/sentry-javascript/blob/3d63621714b31c1ea4c2ab2d90d5684a36805a43/packages/core/src/utils-hoist/url.ts#L55\n\n- [ ] https://github.com/getsentry/sentry-javascript/blob/3d63621714b31c1ea4c2ab2d90d5684a36805a43/packages/bun/src/integrations/bunserver.ts#L10\n- [ ] https://github.com/getsentry/sentry-javascript/blob/3d63621714b31c1ea4c2ab2d90d5684a36805a43/packages/opentelemetry/src/utils/getRequestSpanData.ts#L9\n- [ ] https://github.com/getsentry/sentry-javascript/blob/3d63621714b31c1ea4c2ab2d90d5684a36805a43/packages/node/src/integrations/node-fetch/SentryNodeFetchInstrumentation.ts#L6\n- [ ] https://github.com/getsentry/sentry-javascript/blob/3d63621714b31c1ea4c2ab2d90d5684a36805a43/packages/node/src/integrations/http/SentryHttpInstrumentation.ts#L14\n- [ ] https://github.com/getsentry/sentry-javascript/blob/3d63621714b31c1ea4c2ab2d90d5684a36805a43/packages/opentelemetry/src/utils/parseSpanDescription.ts#L22\n\nReminder list:\n- Can we remove `extractQueryParamsFromUrl`?","author":{"url":"https://github.com/AbhiPrasad","@type":"Person","name":"AbhiPrasad"},"datePublished":"2025-03-21T01:57:03Z","url":"https://github.com/getsentry/sentry-javascript/issues/15767"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:b7f80ef9-8bbd-44c7-304d-afb77d35bd30 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | E29E:14AEA2:1121573:1681936:6B03FD4A |
| html-safe-nonce | bdd406318a15866dbce8908c1dbc4eab530e1b82597b2d99121af88fefb383ed |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJFMjlFOjE0QUVBMjoxMTIxNTczOjE2ODE5MzY6NkIwM0ZENEEiLCJ2aXNpdG9yX2lkIjoiMzY3NzM5NjEyMzU1NzAzNTMzOCIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 0b66b0a240734a5965ff7e2408ccb1c81611bb5336cf849ef7f2af755e9787bb |
| hovercard-subject-tag | issue:2937042931 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/getsentry/sentry-javascript/15767/issue_layout |
| twitter:image | https://opengraph.githubassets.com/cd92a38ff6457e08fe220f327ffc3c3c2a4e3d74cd7fc0c80cbcd003c18a2226/getsentry/sentry-javascript/issues/15767 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/cd92a38ff6457e08fe220f327ffc3c3c2a4e3d74cd7fc0c80cbcd003c18a2226/getsentry/sentry-javascript/issues/15767 |
| og:image:alt | Description Now that we support ES2020 (aka not IE11 anymore) and Node.js 18+, we can get rid of parseUrl in favor of a method that just uses the built-in URL object. This will save us some bundle ... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | AbhiPrasad |
| hostname | github.com |
| expected-hostname | github.com |
| None | 87e774ee7c6b3bee0490394e4d3e57ec9dbc956f74b87ea685dc8996c1676456 |
| turbo-cache-control | no-preview |
| go-import | github.com/getsentry/sentry-javascript git https://github.com/getsentry/sentry-javascript.git |
| octolytics-dimension-user_id | 1396951 |
| octolytics-dimension-user_login | getsentry |
| octolytics-dimension-repository_id | 3328572 |
| octolytics-dimension-repository_nwo | getsentry/sentry-javascript |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 3328572 |
| octolytics-dimension-repository_network_root_nwo | getsentry/sentry-javascript |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 423dbb54c5e7bfecc838eb387c1435eb3d0e760d |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
| Server | github.com |
| Content-Type | text/html; charset=utf-8 |
| Cache-Control | max-age=0, private, must-revalidate |
Viewport: width=device-width