From a120d79585fab9690f4b1fe74d2524909ae708a8 Mon Sep 17 00:00:00 2001 From: Simon Ser Date: Wed, 13 Oct 2021 16:47:01 +0200 Subject: [PATCH] Handle IRC URLs without channel name --- components/app.js | 2 +- lib/irc.js | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/components/app.js b/components/app.js index 1640cbd..eac383c 100644 --- a/components/app.js +++ b/components/app.js @@ -906,7 +906,7 @@ export default class App extends Component { event.preventDefault(); - let buf = State.getBuffer(this.state, { server: serverID, name: url.channel }); + let buf = State.getBuffer(this.state, { server: serverID, name: url.channel || SERVER_BUFFER }); if (buf) { this.switchBuffer(buf.id); } else { diff --git a/lib/irc.js b/lib/irc.js index 95b7860..54f1b9b 100644 --- a/lib/irc.js +++ b/lib/irc.js @@ -666,17 +666,17 @@ export function parseURL(str) { let i = str.indexOf("/"); if (i < 0) { - return null; + return { host: str }; } let host = str.slice(0, i); str = str.slice(i + 1); // TODO: handle URLs with query params - if (!str.startsWith("#")) { - return null; + let channel = null; + if (str.startsWith("#")) { + channel = str; } - let channel = str; return { host, channel }; }