diff --git a/lib/linkify.js b/lib/linkify.js index 61693ab..61f3295 100644 --- a/lib/linkify.js +++ b/lib/linkify.js @@ -2,14 +2,15 @@ import { anchorme, html } from "./index.js"; function linkifyChannel(text, transformChannel) { // Don't match punctuation at the end of the channel name - const channelRegex = /(?:^|\s)(#[^\s]+[^\s.?!…():;,])/gid; + const channelRegex = /(^|\s)(#[^\s]+[^\s.?!…():;,])/gi; let children = []; let match; let last = 0; while ((match = channelRegex.exec(text)) !== null) { - let channel = match[1]; - let [start, end] = match.indices[1]; + let channel = match[2]; + let start = match.index + match[1].length; + let end = start + match[2].length; children.push(text.substring(last, start)); children.push(transformChannel(channel));