Handle click on irc:// channel URLs inside buffers
References: https://todo.sr.ht/~emersion/gamja/71
This commit is contained in:
parent
631f119061
commit
405bc51c26
3 changed files with 72 additions and 28 deletions
24
lib/irc.js
24
lib/irc.js
|
@ -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 };
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue