Handle click on irc:// channel URLs inside buffers

References: https://todo.sr.ht/~emersion/gamja/71
This commit is contained in:
Simon Ser 2021-10-13 16:18:59 +02:00
parent 631f119061
commit 405bc51c26
3 changed files with 72 additions and 28 deletions

View file

@ -656,3 +656,27 @@ export function isMeaningfulRealname(realname, nick) {
return true;
}
export function parseURL(str) {
if (!str.startsWith("irc://") && !str.startsWith("ircs://")) {
return null;
}
str = str.slice(str.indexOf(":") + 3);
let i = str.indexOf("/");
if (i < 0) {
return null;
}
let host = str.slice(0, i);
str = str.slice(i + 1);
// TODO: handle URLs with query params
if (!str.startsWith("#")) {
return null;
}
let channel = str;
return { host, channel };
}