Bluesky app fork with some witchin' additions 💫

Do not render links if uri is invalid (#9663)

* Do not render links if uri is invalid

* Update comment

authored by

Eric Bailey and committed by
GitHub
9aa360d3 2d8de1dd

+5 -1
+5 -1
src/components/RichText.tsx
··· 11 11 import {Text, type TextProps} from '#/components/Typography' 12 12 13 13 const WORD_WRAP = {wordWrap: 1} 14 + // lifted from facet detection in `RichText` impl, _without_ `gm` flags 15 + const URL_REGEX = 16 + /(^|\s|\()((https?:\/\/[\S]+)|((?<domain>[a-z][a-z0-9]*(\.[a-z0-9]+)+)[\S]*))/i 14 17 15 18 export type RichTextProps = TextStyleProp & 16 19 Pick<TextProps, 'selectable' | 'onLayout' | 'onTextLayout'> & { ··· 115 118 </ProfileHoverCard>, 116 119 ) 117 120 } else if (link && AppBskyRichtextFacet.validateLink(link).success) { 118 - if (disableLinks) { 121 + const isValidLink = URL_REGEX.test(link.uri) 122 + if (!isValidLink || disableLinks) { 119 123 els.push(toShortUrl(segment.text)) 120 124 } else { 121 125 els.push(