From 25dee776004d389fb4e18b213a9f7895722af723 Mon Sep 17 00:00:00 2001 From: Adam Williams Date: Sat, 24 Mar 2018 16:44:04 +0000 Subject: [PATCH] Add auto-prepend behaviour for unprefixed channels This change adds behaviour to automatically prefix channel names passed in via the "?join=x,y,z" query string/search parameter which do not appear to include an appropriate channel symbol. --- client/js/lounge.js | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/client/js/lounge.js b/client/js/lounge.js index 0f4b94ae..e4930a11 100644 --- a/client/js/lounge.js +++ b/client/js/lounge.js @@ -585,7 +585,19 @@ $(function() { // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/for...in#Iterating_over_own_properties_only for (let key in params) { if (params.hasOwnProperty(key)) { - const value = params[key]; + let value = params[key]; + + if (key === "join") { + const channels = value.split(","); + value = channels.map((c) => { + if (c.match(/^\w/)) { + return "#" + c; + } + + return c; + }).join(","); + } + // \W searches for non-word characters key = key.replace(/\W/g, "");