MCPcopy Index your code
hub / github.com/getsentry/sentry / addQueryParamsToExistingUrl

Function addQueryParamsToExistingUrl

static/app/utils/queryString.tsx:17–34  ·  view source on GitHub ↗
(
  origUrl: string,
  queryParams: Record<PropertyKey, unknown>
)

Source from the content-addressed store, hash-verified

15export const TAG_VALUE_ESCAPE_PATTERN = '[:\\s\\(\\)\\\\"]';
16
17export function addQueryParamsToExistingUrl(
18 origUrl: string,
19 queryParams: Record<PropertyKey, unknown>
20): string {
21 const url = safeURL(origUrl);
22
23 if (!url) {
24 return '';
25 }
26
27 const searchEntries = url.searchParams.entries();
28 // Order the query params alphabetically.
29 // Otherwise ``queryString`` orders them randomly and it's impossible to test.
30 const params = JSON.parse(JSON.stringify(queryParams));
31 const query = {...Object.fromEntries(searchEntries), ...params};
32
33 return `${url.protocol}//${url.host}${url.pathname}?${qs.stringify(query)}`;
34}
35
36export type QueryValue = string | string[] | undefined | null;
37

Callers 8

getFieldDefaultFunction · 0.90
getUrlFunction · 0.90
SentryAppDetailedViewFunction · 0.90

Calls 3

safeURLFunction · 0.90
entriesMethod · 0.80
parseMethod · 0.45

Tested by

no test coverage detected