query.tsx 521 B

1234567891011121314151617181920212223
  1. import type {Location} from 'history';
  2. import {defined} from 'sentry/utils';
  3. import {decodeQuery} from 'sentry/utils/discover/eventView';
  4. export function defaultQuery(): string {
  5. return '';
  6. }
  7. export function getQueryFromLocation(location: Location) {
  8. return decodeQuery(location);
  9. }
  10. export function updateLocationWithQuery(
  11. location: Location,
  12. query: string | null | undefined
  13. ) {
  14. if (defined(query)) {
  15. location.query.query = query;
  16. } else if (query === null) {
  17. delete location.query.query;
  18. }
  19. }