[polari] ircParser: Allow /join command without '#' prefix



commit f881a94c4a4b6e81b7f1201e3b6c7ba603c4173e
Author: Jack Gleeson <jack jpgleeson com>
Date:   Wed Apr 28 14:30:35 2021 -0400

    ircParser: Allow /join command without '#' prefix
    
    We don't show the '#' prefix in the UI, but require it in the
    /join command. That's unexpected, so allow omitting the prefix
    and add it if not present.
    
    https://gitlab.gnome.org/GNOME/polari/-/issues/167

 src/ircParser.js | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
---
diff --git a/src/ircParser.js b/src/ircParser.js
index c41a93cf..5de8d74c 100644
--- a/src/ircParser.js
+++ b/src/ircParser.js
@@ -48,6 +48,8 @@ export const knownCommands = {
 const UNKNOWN_COMMAND_MESSAGE =
     N_('Unknown command — try /HELP for a list of available commands');
 
+const ROOM_PREFIXES = ['#', '&', '+', '!'];
+
 const IrcParser = class IrcParser {
     constructor(room) {
         this._app = Gio.Application.get_default();
@@ -128,7 +130,8 @@ const IrcParser = class IrcParser {
             }
             if (argv.length)
                 log(`Excess arguments to JOIN command: ${argv}`);
-
+            if (!ROOM_PREFIXES.some(prefix => room.startsWith(prefix)))
+                room = `#${room}`;
             let { account } = this._room;
             let app = Gio.Application.get_default();
             let action = app.lookup_action('join-room');


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]