|
|
@ -33,13 +33,13 @@ type IrcMessage = { |
|
|
|
content: MessageFrag[] |
|
|
|
}; |
|
|
|
|
|
|
|
const URLScheme = /https?:\/\/[\w\.\/\?\=\-]+/; |
|
|
|
const URL = /https?:\/\/(\w|[\&\%\.\/\?\=\-\#])+/; |
|
|
|
|
|
|
|
function parseMessage(m: string): MessageFrag[] { |
|
|
|
m = m.trimEnd(); |
|
|
|
const parts: MessageFrag[] = []; |
|
|
|
let match: RegExpMatchArray | null; |
|
|
|
while ((match = m.match(URLScheme)) != null) { |
|
|
|
while ((match = m.match(URL)) != null) { |
|
|
|
parts.push({ type: 'text', content: m.slice(0, match.index) }); |
|
|
|
parts.push({ type: 'url', link: match[0] }); |
|
|
|
m = m.slice((match.index ?? 0) + match[0].length); |
|
|
|