Browse Source

update URL re

master
Amélia Liao 2 years ago
parent
commit
6e6cbb633a
1 changed files with 2 additions and 2 deletions
  1. +2
    -2
      src/main.tsx

+ 2
- 2
src/main.tsx View File

@ -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);


Loading…
Cancel
Save