this repo has no description
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

Replace lookbehind regex

because older Safari doesn't support it

+6 -6
+6 -6
src/components/compose.jsx
··· 107 107 // https://github.com/mastodon/mastodon/blob/c03bd2a238741a012aa4b98dc4902d6cf948ab63/app/models/account.rb#L69 108 108 const USERNAME_RE = /[a-z0-9_]+([a-z0-9_.-]+[a-z0-9_]+)?/i; 109 109 const MENTION_RE = new RegExp( 110 - `(?<![=\\/\\w])@((${USERNAME_RE.source})(?:@[\\w.-]+[\\w]+)?)`, 110 + `(^|[^=\\/\\w])(@${USERNAME_RE.source}(?:@[\\w.-]+[\\w]+)?)`, 111 111 'ig', 112 112 ); 113 113 114 114 // AI-generated, all other regexes are too complicated 115 115 const HASHTAG_RE = new RegExp( 116 - `(?<![=\\/\\w])#([a-z0-9_]+([a-z0-9_.-]+[a-z0-9_]+)?)(?![\\/\\w])`, 116 + `(^|[^=\\/\\w])(#[a-z0-9_]+([a-z0-9_.-]+[a-z0-9_]+)?)(?![\\/\\w])`, 117 117 'ig', 118 118 ); 119 119 120 120 // https://github.com/mastodon/mastodon/blob/23e32a4b3031d1da8b911e0145d61b4dd47c4f96/app/models/custom_emoji.rb#L31 121 121 const SHORTCODE_RE_FRAGMENT = '[a-zA-Z0-9_]{2,}'; 122 122 const SCAN_RE = new RegExp( 123 - `(?<=[^A-Za-z0-9_:\\n]|^):(${SHORTCODE_RE_FRAGMENT}):(?=[^A-Za-z0-9_:]|$)`, 123 + `([^A-Za-z0-9_:\\n]|^)(:${SHORTCODE_RE_FRAGMENT}:)(?=[^A-Za-z0-9_:]|$)`, 124 124 'g', 125 125 ); 126 126 ··· 142 142 143 143 html = html 144 144 .replace(urlRegexObj, '$2<mark class="compose-highlight-url">$3</mark>') // URLs 145 - .replace(MENTION_RE, '<mark class="compose-highlight-mention">$&</mark>') // Mentions 146 - .replace(HASHTAG_RE, '<mark class="compose-highlight-hashtag">#$1</mark>') // Hashtags 145 + .replace(MENTION_RE, '$1<mark class="compose-highlight-mention">$2</mark>') // Mentions 146 + .replace(HASHTAG_RE, '$1<mark class="compose-highlight-hashtag">$2</mark>') // Hashtags 147 147 .replace( 148 148 SCAN_RE, 149 - '<mark class="compose-highlight-emoji-shortcode">$&</mark>', 149 + '$1<mark class="compose-highlight-emoji-shortcode">$2</mark>', 150 150 ); // Emoji shortcodes 151 151 152 152 return html + leftoverHTML;