Browse Source

ref: Move isUrl out of utils.tsx (#71843)

Related to https://github.com/getsentry/frontend-tsc/issues/13
Ryan Albrecht 9 months ago
parent
commit
6824e0ab02

+ 1 - 1
static/app/components/events/eventTags/eventTagContent.tsx

@@ -10,7 +10,7 @@ import VersionHoverCard from 'sentry/components/versionHoverCard';
 import {IconOpen} from 'sentry/icons';
 import type {EventTag} from 'sentry/types/event';
 import type {Organization} from 'sentry/types/organization';
-import {isUrl} from 'sentry/utils';
+import {isUrl} from 'sentry/utils/string/isUrl';
 
 const iconStyle = css`
   position: relative;

+ 2 - 1
static/app/components/events/eventTags/eventTagsTreeRow.tsx

@@ -18,7 +18,8 @@ import {t} from 'sentry/locale';
 import {space} from 'sentry/styles/space';
 import type {Project} from 'sentry/types';
 import type {Event} from 'sentry/types/event';
-import {generateQueryWithTag, isUrl, objectIsEmpty} from 'sentry/utils';
+import {generateQueryWithTag, objectIsEmpty} from 'sentry/utils';
+import {isUrl} from 'sentry/utils/string/isUrl';
 import useCopyToClipboard from 'sentry/utils/useCopyToClipboard';
 import useMutateProject from 'sentry/utils/useMutateProject';
 import useOrganization from 'sentry/utils/useOrganization';

+ 1 - 1
static/app/components/events/interfaces/crashContent/exception/mechanism.tsx

@@ -12,7 +12,7 @@ import {IconOpen} from 'sentry/icons';
 import {t} from 'sentry/locale';
 import {space} from 'sentry/styles/space';
 import type {StackTraceMechanism} from 'sentry/types/stacktrace';
-import {isUrl} from 'sentry/utils';
+import {isUrl} from 'sentry/utils/string/isUrl';
 
 type Props = {
   data: StackTraceMechanism;

+ 1 - 1
static/app/components/events/interfaces/crashContent/exception/utils.tsx

@@ -6,8 +6,8 @@ import {openNavigateToExternalLinkModal} from 'sentry/actionCreators/modal';
 import ExternalLink from 'sentry/components/links/externalLink';
 import {IconOpen} from 'sentry/icons';
 import type {Frame} from 'sentry/types';
-import {isUrl} from 'sentry/utils';
 import {getFileExtension} from 'sentry/utils/fileExtension';
+import {isUrl} from 'sentry/utils/string/isUrl';
 import {safeURL} from 'sentry/utils/url/safeURL';
 
 const fileNameBlocklist = ['@webkit-masked-url'];

+ 2 - 1
static/app/components/events/interfaces/frame/defaultTitle/index.tsx

@@ -10,7 +10,8 @@ import {IconOpen, IconQuestion} from 'sentry/icons';
 import {t} from 'sentry/locale';
 import {space} from 'sentry/styles/space';
 import type {Frame, Meta, PlatformKey} from 'sentry/types';
-import {defined, isUrl} from 'sentry/utils';
+import {defined} from 'sentry/utils';
+import {isUrl} from 'sentry/utils/string/isUrl';
 
 import {FunctionName} from '../functionName';
 import GroupingIndicator from '../groupingIndicator';

+ 1 - 1
static/app/components/events/interfaces/request/getUrlFromEvent.tsx

@@ -1,7 +1,7 @@
 import {getFullUrl} from 'sentry/components/events/interfaces/utils';
 import type {EntryRequest, Event} from 'sentry/types/event';
 import {EntryType} from 'sentry/types/event';
-import {isUrl} from 'sentry/utils';
+import {isUrl} from 'sentry/utils/string/isUrl';
 
 function getUrlFromEvent(event: Event): string {
   const requestEntry = event.entries.find(

+ 2 - 1
static/app/components/events/interfaces/request/index.tsx

@@ -15,7 +15,8 @@ import {t} from 'sentry/locale';
 import {space} from 'sentry/styles/space';
 import type {EntryRequest, Event} from 'sentry/types/event';
 import {EntryType} from 'sentry/types/event';
-import {defined, isUrl} from 'sentry/utils';
+import {defined} from 'sentry/utils';
+import {isUrl} from 'sentry/utils/string/isUrl';
 
 import {RichHttpContentClippedBoxBodySection} from './richHttpContentClippedBoxBodySection';
 import {RichHttpContentClippedBoxKeyValueList} from './richHttpContentClippedBoxKeyValueList';

+ 2 - 1
static/app/components/structuredEventData/index.tsx

@@ -7,7 +7,8 @@ import ExternalLink from 'sentry/components/links/externalLink';
 import {CollapsibleValue} from 'sentry/components/structuredEventData/collapsibleValue';
 import {IconOpen} from 'sentry/icons';
 import {t} from 'sentry/locale';
-import {defined, isUrl} from 'sentry/utils';
+import {defined} from 'sentry/utils';
+import {isUrl} from 'sentry/utils/string/isUrl';
 
 import {
   looksLikeMultiLineString,

+ 1 - 1
static/app/components/tagsTableRow.tsx

@@ -10,7 +10,7 @@ import Version from 'sentry/components/version';
 import {IconOpen} from 'sentry/icons';
 import {t} from 'sentry/locale';
 import type {EventTag} from 'sentry/types/event';
-import {isUrl} from 'sentry/utils';
+import {isUrl} from 'sentry/utils/string/isUrl';
 
 interface Props {
   generateUrl: (tag: EventTag) => LocationDescriptor;

+ 0 - 11
static/app/utils.tsx

@@ -100,17 +100,6 @@ export function nl2br(str: string): string {
   return str.replace(/(?:\r\n|\r|\n)/g, '<br />');
 }
 
-/**
- * This function has a critical security impact, make sure to check all usages before changing this function.
- * In some parts of our code we rely on that this only really is a string starting with http(s).
- */
-export function isUrl(str: any): boolean {
-  return (
-    typeof str === 'string' &&
-    (str.indexOf('http://') === 0 || str.indexOf('https://') === 0)
-  );
-}
-
 export function escape(str: string): string {
   return str.replace(/&/g, '&amp;').replace(/</g, '&lt;').replace(/>/g, '&gt;');
 }

Some files were not shown because too many files changed in this diff