MCPcopy Index your code
hub / github.com/getsentry/sentry-javascript / parseUrl

Function parseUrl

packages/core/src/utils/url.ts:214–236  ·  view source on GitHub ↗
(url: string)

Source from the content-addressed store, hash-verified

212 * @returns parsed URL object
213 */
214export function parseUrl(url: string): PartialURL {
215 if (!url) {
216 return {};
217 }
218
219 const match = url.match(/^(([^:/?#]+):)?(\/\/([^/?#]*))?([^?#]*)(\?([^#]*))?(#(.*))?$/);
220
221 if (!match) {
222 return {};
223 }
224
225 // coerce to undefined values to empty string so we don't get 'undefined'
226 const query = match[6] || '';
227 const fragment = match[8] || '';
228 return {
229 host: match[4],
230 path: match[5],
231 protocol: match[2],
232 search: query,
233 hash: fragment,
234 relative: match[5] + query + fragment, // everything minus origin
235 };
236}
237
238/**
239 * Strip the query string and fragment off of a given URL or path (if present)

Callers 11

extractErrorContextFunction · 0.90
captureErrorHookFunction · 0.90
url.test.tsFile · 0.90
getBreadcrumbDataFunction · 0.90
_addResourceSpansFunction · 0.90
getRequestSpanDataFunction · 0.90
getSanitizedUrlFunction · 0.90
xhrCallbackFunction · 0.85

Calls 1

matchMethod · 0.80

Tested by

no test coverage detected