12345678910111213141516171819202122232425262728293031323334353637383940414243 |
- import {useContext} from 'react';
- import ConfigStore from 'sentry/stores/configStore';
- import {OrganizationSummary} from 'sentry/types';
- import {OrganizationContext} from 'sentry/views/organizationContext';
- import shouldUseLegacyRoute from './shouldUseLegacyRoute';
- import {normalizeUrl} from './withDomainRequired';
- function useResolveRoute(route: string, organization?: OrganizationSummary) {
- const {sentryUrl} = ConfigStore.get('links');
- const currentOrganization = useContext(OrganizationContext);
- const hasCustomerDomain = currentOrganization?.features.includes('customer-domains');
- if (!organization) {
- if (hasCustomerDomain) {
- return `${sentryUrl}${normalizeUrl(route)}`;
- }
- return route;
- }
- const {organizationUrl} = organization.links;
- const useLegacyRoute = shouldUseLegacyRoute(organization);
- if (useLegacyRoute) {
- if (hasCustomerDomain) {
-
-
- return `${sentryUrl}${route}`;
- }
- return route;
- }
- return `${organizationUrl}${normalizeUrl(route)}`;
- }
- export default useResolveRoute;
|