diff --git a/static/app/components/globalSelectionLink.tsx b/static/app/components/globalSelectionLink.tsx index 9deb11df5588e..9f0f4a0ebfb59 100644 --- a/static/app/components/globalSelectionLink.tsx +++ b/static/app/components/globalSelectionLink.tsx @@ -42,6 +42,10 @@ function GlobalSelectionLink(props: Props) { const query = typeof to === 'object' && to.query ? {...globalQuery, ...to.query} : globalQuery; + if (typeof to === 'object' && to.query && Object.keys(to.query).length === 0) { + delete to.query; + } + if (location) { const toWithGlobalQuery: LocationDescriptor = !hasGlobalQuery ? {} @@ -49,6 +53,10 @@ function GlobalSelectionLink(props: Props) { ? {pathname: to, query} : {...to, query}; + if (toWithGlobalQuery.query && Object.keys(toWithGlobalQuery.query).length === 0) { + delete toWithGlobalQuery.query; + } + const routerProps = hasGlobalQuery ? {...props, to: toWithGlobalQuery} : {...props, to}; diff --git a/static/app/components/profiling/profilingBreadcrumbs.spec.tsx b/static/app/components/profiling/profilingBreadcrumbs.spec.tsx index b2ce52237bd05..e38424c09f834 100644 --- a/static/app/components/profiling/profilingBreadcrumbs.spec.tsx +++ b/static/app/components/profiling/profilingBreadcrumbs.spec.tsx @@ -27,7 +27,7 @@ describe('Breadcrumb', function () { expect(screen.getByText('Profiling')).toBeInTheDocument(); expect(screen.getByRole('link', {name: 'Profiling'})).toHaveAttribute( 'href', - `/organizations/${organization.slug}/profiling/?` + `/organizations/${organization.slug}/profiling/` ); expect(screen.getByText('foo')).toBeInTheDocument(); });