Enforce dangling commas with ESLint

¯\_(ツ)_/¯
This commit is contained in:
Jérémie Astori 2017-11-15 01:35:15 -05:00
parent f0a9fdb658
commit 1dc92d8934
No known key found for this signature in database
GPG key ID: B9A4F245CD67BDE8
89 changed files with 385 additions and 383 deletions

View file

@ -15,7 +15,9 @@ rules:
block-scoped-var: error block-scoped-var: error
block-spacing: [error, always] block-spacing: [error, always]
brace-style: [error, 1tbs] brace-style: [error, 1tbs]
comma-dangle: off comma-dangle:
- error
- always-multiline
curly: [error, all] curly: [error, all]
dot-location: [error, property] dot-location: [error, property]
dot-notation: error dot-notation: error

View file

@ -26,7 +26,7 @@ const emojiStrategy = {
replace([, original]) { replace([, original]) {
return emojiMap[original]; return emojiMap[original];
}, },
index: 1 index: 1,
}; };
const nicksStrategy = { const nicksStrategy = {
@ -41,13 +41,13 @@ const nicksStrategy = {
callback(completeNicks(term, true)); callback(completeNicks(term, true));
} }
}, },
template([string, ]) { template([string]) {
return string; return string;
}, },
replace([, original]) { replace([, original]) {
return original; return original;
}, },
index: 1 index: 1,
}; };
const chanStrategy = { const chanStrategy = {
@ -56,13 +56,13 @@ const chanStrategy = {
search(term, callback, match) { search(term, callback, match) {
callback(completeChans(match[0])); callback(completeChans(match[0]));
}, },
template([string,]) { template([string]) {
return string; return string;
}, },
replace([, original]) { replace([, original]) {
return original; return original;
}, },
index: 1 index: 1,
}; };
const commandStrategy = { const commandStrategy = {
@ -71,13 +71,13 @@ const commandStrategy = {
search(term, callback) { search(term, callback) {
callback(completeCommands("/" + term)); callback(completeCommands("/" + term));
}, },
template([string, ]) { template([string]) {
return string; return string;
}, },
replace([, original]) { replace([, original]) {
return original; return original;
}, },
index: 1 index: 1,
}; };
const foregroundColorStrategy = { const foregroundColorStrategy = {
@ -92,7 +92,7 @@ const foregroundColorStrategy = {
if (fuzzy.test(term, i[1])) { if (fuzzy.test(term, i[1])) {
return [i[0], fuzzy.match(term, i[1], { return [i[0], fuzzy.match(term, i[1], {
pre: "<b>", pre: "<b>",
post: "</b>" post: "</b>",
}).rendered]; }).rendered];
} }
return i; return i;
@ -106,7 +106,7 @@ const foregroundColorStrategy = {
replace(value) { replace(value) {
return "\x03" + value[0]; return "\x03" + value[0];
}, },
index: 1 index: 1,
}; };
const backgroundColorStrategy = { const backgroundColorStrategy = {
@ -120,7 +120,7 @@ const backgroundColorStrategy = {
if (fuzzy.test(term, pair[1])) { if (fuzzy.test(term, pair[1])) {
return [pair[0], fuzzy.match(term, pair[1], { return [pair[0], fuzzy.match(term, pair[1], {
pre: "<b>", pre: "<b>",
post: "</b>" post: "</b>",
}).rendered]; }).rendered];
} }
return pair; return pair;
@ -135,7 +135,7 @@ const backgroundColorStrategy = {
replace(value) { replace(value) {
return "\x03$1," + value[0]; return "\x03$1," + value[0];
}, },
index: 2 index: 2,
}; };
const input = $("#input") const input = $("#input")
@ -151,17 +151,17 @@ if (options.autocomplete) {
function enableAutocomplete() { function enableAutocomplete() {
input.textcomplete([ input.textcomplete([
emojiStrategy, nicksStrategy, chanStrategy, commandStrategy, emojiStrategy, nicksStrategy, chanStrategy, commandStrategy,
foregroundColorStrategy, backgroundColorStrategy foregroundColorStrategy, backgroundColorStrategy,
], { ], {
dropdownClassName: "textcomplete-menu", dropdownClassName: "textcomplete-menu",
placement: "top" placement: "top",
}).on({ }).on({
"textComplete:show": function() { "textComplete:show": function() {
$(this).data("autocompleting", true); $(this).data("autocompleting", true);
}, },
"textComplete:hide": function() { "textComplete:hide": function() {
$(this).data("autocompleting", false); $(this).data("autocompleting", false);
} },
}); });
} }
@ -171,7 +171,7 @@ function fuzzyGrep(term, array) {
array, array,
{ {
pre: "<b>", pre: "<b>",
post: "</b>" post: "</b>",
} }
); );
return results.map((el) => [el.string, el.original]); return results.map((el) => [el.string, el.original]);

View file

@ -4,7 +4,7 @@ const constants = require("./constants");
const templates = require("../views"); const templates = require("../views");
module.exports = { module.exports = {
updateText updateText,
}; };
function updateText(condensed, addedTypes) { function updateText(condensed, addedTypes) {

View file

@ -65,7 +65,7 @@ const commands = [
"/topic", "/topic",
"/unban", "/unban",
"/voice", "/voice",
"/whois" "/whois",
]; ];
const actionTypes = [ const actionTypes = [
@ -100,7 +100,7 @@ const condensedTypes = [
const timeFormats = { const timeFormats = {
msgDefault: "HH:mm", msgDefault: "HH:mm",
msgWithSeconds: "HH:mm:ss" msgWithSeconds: "HH:mm:ss",
}; };
module.exports = { module.exports = {
@ -109,5 +109,5 @@ module.exports = {
condensedTypes: condensedTypes, condensedTypes: condensedTypes,
condensedTypesQuery: "." + condensedTypes.join(", ."), condensedTypesQuery: "." + condensedTypes.join(", ."),
actionTypes: actionTypes, actionTypes: actionTypes,
timeFormats: timeFormats timeFormats: timeFormats,
}; };

View file

@ -9,7 +9,7 @@ const contextMenuContainer = $("#context-menu-container");
Mousetrap.bind([ Mousetrap.bind([
"pageup", "pageup",
"pagedown" "pagedown",
], function(e, key) { ], function(e, key) {
let container = windows.find(".window.active"); let container = windows.find(".window.active");
@ -30,7 +30,7 @@ Mousetrap.bind([
} }
container.animate({ container.animate({
scrollTop: scrollTop scrollTop: scrollTop,
}, 200); }, 200);
return false; return false;
@ -40,7 +40,7 @@ Mousetrap.bind([
"command+up", "command+up",
"command+down", "command+down",
"ctrl+up", "ctrl+up",
"ctrl+down" "ctrl+down",
], function(e, keys) { ], function(e, keys) {
const channels = sidebar.find(".chan"); const channels = sidebar.find(".chan");
const index = channels.index(channels.filter(".active")); const index = channels.index(channels.filter(".active"));
@ -61,7 +61,7 @@ Mousetrap.bind([
}); });
Mousetrap.bind([ Mousetrap.bind([
"escape" "escape",
], function() { ], function() {
contextMenuContainer.hide(); contextMenuContainer.hide();
}); });
@ -77,7 +77,7 @@ const colorsHotkeys = {
for (const hotkey in colorsHotkeys) { for (const hotkey in colorsHotkeys) {
Mousetrap.bind([ Mousetrap.bind([
"command+" + hotkey, "command+" + hotkey,
"ctrl+" + hotkey "ctrl+" + hotkey,
], function(e) { ], function(e) {
e.preventDefault(); e.preventDefault();

View file

@ -8,6 +8,6 @@ module.exports = function(time) {
sameDay: "[Today]", sameDay: "[Today]",
lastDay: "[Yesterday]", lastDay: "[Yesterday]",
lastWeek: "D MMMM YYYY", lastWeek: "D MMMM YYYY",
sameElse: "D MMMM YYYY" sameElse: "D MMMM YYYY",
}); });
}; };

View file

@ -13,7 +13,7 @@ function fill(existingEntries, text) {
if (textSegment.start > position) { if (textSegment.start > position) {
acc.push({ acc.push({
start: position, start: position,
end: textSegment.start end: textSegment.start,
}); });
} }
position = textSegment.end; position = textSegment.end;
@ -24,7 +24,7 @@ function fill(existingEntries, text) {
if (position < text.length) { if (position < text.length) {
result.push({ result.push({
start: position, start: position,
end: text.length end: text.length,
}); });
} }

View file

@ -32,7 +32,7 @@ function findChannels(text, channelPrefixes, userModes) {
result.push({ result.push({
start: match.index + match[0].length - match[1].length, start: match.index + match[0].length - match[1].length,
end: match.index + match[0].length, end: match.index + match[0].length,
channel: match[1] channel: match[1],
}); });
} }
} while (match); } while (match);

View file

@ -10,7 +10,7 @@ function findEmoji(text) {
result.push({ result.push({
start: match.index, start: match.index,
end: match.index + match[0].length, end: match.index + match[0].length,
emoji: match[0] emoji: match[0],
}); });
} }

View file

@ -55,7 +55,7 @@ function findLinks(text) {
result.push({ result.push({
start: start, start: start,
end: end, end: end,
link: url link: url,
}); });
}); });
} catch (e) { } catch (e) {

View file

@ -25,7 +25,7 @@ function assign(textPart, fragment) {
return Object_assign({}, fragment, { return Object_assign({}, fragment, {
start: start, start: start,
end: end, end: end,
text: fragment.text.slice(start - fragStart, end - fragStart) text: fragment.text.slice(start - fragStart, end - fragStart),
}); });
} }

View file

@ -70,7 +70,7 @@ function parseStyle(text) {
underline, underline,
text: processedText, text: processedText,
start: fragmentStart, start: fragmentStart,
end: fragmentStart + processedText.length end: fragmentStart + processedText.length,
}); });
} }

View file

@ -8,7 +8,7 @@ module.exports = function(mode) {
"@": "op", "@": "op",
"%": "half-op", "%": "half-op",
"+": "voice", "+": "voice",
"": "normal" "": "normal",
}; };
return modes[mode]; return modes[mode];
}; };

View file

@ -98,6 +98,6 @@ module.exports = function slideoutMenu(viewport, menu) {
toggle: toggleMenu, toggle: toggleMenu,
isOpen: function() { isOpen: function() {
return menuIsOpen; return menuIsOpen;
} },
}; };
}; };

View file

@ -15,5 +15,5 @@ module.exports = {
}, },
remove: function(key, value) { remove: function(key, value) {
window.localStorage.removeItem(key, value); window.localStorage.removeItem(key, value);
} },
}; };

View file

@ -82,19 +82,19 @@ $(function() {
output = templates.contextmenu_item({ output = templates.contextmenu_item({
class: "user", class: "user",
text: target.text(), text: target.text(),
data: target.data("name") data: target.data("name"),
}); });
} else if (target.hasClass("chan")) { } else if (target.hasClass("chan")) {
output = templates.contextmenu_item({ output = templates.contextmenu_item({
class: "chan", class: "chan",
text: target.data("title"), text: target.data("title"),
data: target.data("target") data: target.data("target"),
}); });
output += templates.contextmenu_divider(); output += templates.contextmenu_divider();
output += templates.contextmenu_item({ output += templates.contextmenu_item({
class: "close", class: "close",
text: target.hasClass("lobby") ? "Disconnect" : target.hasClass("channel") ? "Leave" : "Close", text: target.hasClass("lobby") ? "Disconnect" : target.hasClass("channel") ? "Leave" : "Close",
data: target.data("target") data: target.data("target"),
}); });
} }
@ -196,7 +196,7 @@ $(function() {
socket.emit("input", { socket.emit("input", {
target: chat.data("id"), target: chat.data("id"),
text: text text: text,
}); });
}); });
@ -240,7 +240,7 @@ $(function() {
socket.emit("input", { socket.emit("input", {
target: chat.data("id"), target: chat.data("id"),
text: "/nick " + newNick text: "/nick " + newNick,
}); });
} }
@ -275,7 +275,7 @@ $(function() {
} else { } else {
socket.emit("input", { socket.emit("input", {
target: chat.data("id"), target: chat.data("id"),
text: "/join " + name text: "/join " + name,
}); });
} }
}); });
@ -294,7 +294,7 @@ $(function() {
socket.emit("input", { socket.emit("input", {
target: chat.data("id"), target: chat.data("id"),
text: "/whois " + name text: "/whois " + name,
}); });
}); });
@ -434,11 +434,11 @@ $(function() {
} }
socket.emit("input", { socket.emit("input", {
target: chan.data("id"), target: chan.data("id"),
text: cmd text: cmd,
}); });
chan.css({ chan.css({
transition: "none", transition: "none",
opacity: 0.4 opacity: 0.4,
}); });
return false; return false;
}); });
@ -472,7 +472,7 @@ $(function() {
const fuzzyOptions = { const fuzzyOptions = {
pre: "<b>", pre: "<b>",
post: "</b>", post: "</b>",
extract: (el) => $(el).text() extract: (el) => $(el).text(),
}; };
const result = fuzzy.filter( const result = fuzzy.filter(
@ -620,7 +620,7 @@ $(function() {
// Emit the click to the target, while making sure it is not going to be // Emit the click to the target, while making sure it is not going to be
// added to the state again. // added to the state again.
$(clickTarget).trigger("click", { $(clickTarget).trigger("click", {
pushState: false pushState: false,
}); });
} }
}); });

View file

@ -17,7 +17,7 @@ require("intersection-observer");
const historyObserver = window.IntersectionObserver ? const historyObserver = window.IntersectionObserver ?
new window.IntersectionObserver(loadMoreHistory, { new window.IntersectionObserver(loadMoreHistory, {
root: chat.get(0) root: chat.get(0),
}) : null; }) : null;
module.exports = { module.exports = {
@ -175,7 +175,7 @@ function renderNetworks(data, singleNetwork) {
sidebar.find(".empty").hide(); sidebar.find(".empty").hide();
sidebar.find(".networks").append( sidebar.find(".networks").append(
templates.network({ templates.network({
networks: data.networks networks: data.networks,
}) })
); );
@ -222,7 +222,7 @@ function renderNetworks(data, singleNetwork) {
chat.append( chat.append(
templates.chat({ templates.chat({
channels: channels channels: channels,
}) })
); );

View file

@ -75,7 +75,7 @@ function openCorrectChannel(clientActive, serverActive) {
// If target channel is found, open it // If target channel is found, open it
if (target.length > 0) { if (target.length > 0) {
target.trigger("click", { target.trigger("click", {
replaceHistory: true replaceHistory: true,
}); });
return; return;
@ -83,6 +83,6 @@ function openCorrectChannel(clientActive, serverActive) {
// Open the connect window // Open the connect window
$("#footer .connect").trigger("click", { $("#footer .connect").trigger("click", {
pushState: false pushState: false,
}); });
} }

View file

@ -12,12 +12,12 @@ socket.on("join", function(data) {
const network = sidebar.find("#network-" + id); const network = sidebar.find("#network-" + id);
network.append( network.append(
templates.chan({ templates.chan({
channels: [data.chan] channels: [data.chan],
}) })
); );
chat.append( chat.append(
templates.chat({ templates.chat({
channels: [data.chan] channels: [data.chan],
}) })
); );
render.renderChannel(data.chan); render.renderChannel(data.chan);

View file

@ -92,6 +92,6 @@ chat.on("click", ".show-more-button", function() {
socket.emit("more", { socket.emit("more", {
target: self.data("id"), target: self.data("id"),
lastId: lastMessageId lastId: lastMessageId,
}); });
}); });

View file

@ -15,7 +15,7 @@ try {
pop.src = "audio/pop.ogg"; pop.src = "audio/pop.ogg";
} catch (e) { } catch (e) {
pop = { pop = {
play: $.noop play: $.noop,
}; };
} }
@ -134,7 +134,7 @@ function notifyMessage(targetId, channel, msg) {
const notify = new Notification(title, { const notify = new Notification(title, {
body: body, body: body,
icon: "img/logo-64.png", icon: "img/logo-64.png",
tag: `lounge-${targetId}` tag: `lounge-${targetId}`,
}); });
notify.addEventListener("click", function() { notify.addEventListener("click", function() {
window.focus(); window.focus();

View file

@ -9,7 +9,7 @@ socket.on("users", function(data) {
if (chan.hasClass("active")) { if (chan.hasClass("active")) {
socket.emit("names", { socket.emit("names", {
target: data.chan target: data.chan,
}); });
} else { } else {
chan.data("needsNamesRefresh", true); chan.data("needsNamesRefresh", true);

View file

@ -10,7 +10,7 @@ const socket = io({
transports: $(document.body).data("transports"), transports: $(document.body).data("transports"),
path: path, path: path,
autoConnect: false, autoConnect: false,
reconnection: !$(document.body).hasClass("public") reconnection: !$(document.body).hasClass("public"),
}); });
socket.on("disconnect", handleDisconnect); socket.on("disconnect", handleDisconnect);

View file

@ -26,12 +26,12 @@ module.exports = function() {
socket.emit( socket.emit(
"sort", { "sort", {
type: "networks", type: "networks",
order: order order: order,
} }
); );
options.ignoreSortSync = true; options.ignoreSortSync = true;
} },
}); });
sidebar.find(".network").sortable({ sidebar.find(".network").sortable({
axis: "y", axis: "y",
@ -54,11 +54,11 @@ module.exports = function() {
"sort", { "sort", {
type: "channels", type: "channels",
target: network.data("id"), target: network.data("id"),
order: order order: order,
} }
); );
options.ignoreSortSync = true; options.ignoreSortSync = true;
} },
}); });
}; };

View file

@ -68,7 +68,7 @@ function onPushButton() {
return registration.pushManager.subscribe({ return registration.pushManager.subscribe({
applicationServerKey: urlBase64ToUint8Array(applicationServerKey), applicationServerKey: urlBase64ToUint8Array(applicationServerKey),
userVisibleOnly: true userVisibleOnly: true,
}).then((subscription) => { }).then((subscription) => {
const rawKey = subscription.getKey ? subscription.getKey("p256dh") : ""; const rawKey = subscription.getKey ? subscription.getKey("p256dh") : "";
const key = rawKey ? window.btoa(String.fromCharCode.apply(null, new Uint8Array(rawKey))) : ""; const key = rawKey ? window.btoa(String.fromCharCode.apply(null, new Uint8Array(rawKey))) : "";
@ -80,8 +80,8 @@ function onPushButton() {
endpoint: subscription.endpoint, endpoint: subscription.endpoint,
keys: { keys: {
p256dh: key, p256dh: key,
auth: authSecret auth: authSecret,
} },
}); });
return true; return true;

View file

@ -17,7 +17,7 @@ self.addEventListener("push", function(event) {
event.waitUntil( event.waitUntil(
self.registration self.registration
.getNotifications({ .getNotifications({
tag: `chan-${payload.chanId}` tag: `chan-${payload.chanId}`,
}) })
.then((notifications) => { .then((notifications) => {
for (const notification of notifications) { for (const notification of notifications) {
@ -39,7 +39,7 @@ self.addEventListener("notificationclick", function(event) {
event.notification.close(); event.notification.close();
event.waitUntil(clients.matchAll({ event.waitUntil(clients.matchAll({
type: "window" type: "window",
}).then(function(clientList) { }).then(function(clientList) {
for (var i = 0; i < clientList.length; i++) { for (var i = 0; i < clientList.length; i++) {
var client = clientList[i]; var client = clientList[i];

View file

@ -172,7 +172,7 @@ module.exports = {
// @type string // @type string
// @default "UTC+00:00" // @default "UTC+00:00"
// //
timezone: "UTC+00:00" timezone: "UTC+00:00",
}, },
// //
@ -264,7 +264,7 @@ module.exports = {
// @type string // @type string
// @default "#thelounge" // @default "#thelounge"
// //
join: "#thelounge" join: "#thelounge",
}, },
// //
@ -316,7 +316,7 @@ module.exports = {
// @example "sslcert/bundle.pem" // @example "sslcert/bundle.pem"
// @default "" // @default ""
// //
ca: "" ca: "",
}, },
// //
@ -348,7 +348,7 @@ module.exports = {
// @type int // @type int
// @default 113 // @default 113
// //
port: 113 port: 113,
}, },
// //
@ -482,9 +482,9 @@ module.exports = {
// @type string // @type string
// @default "sub" // @default "sub"
// //
scope: "sub" scope: "sub",
} },
}, },
// Extra debugging // Extra debugging

View file

@ -34,7 +34,7 @@ var events = [
"topic", "topic",
"welcome", "welcome",
"list", "list",
"whois" "whois",
]; ];
var inputs = [ var inputs = [
"ban", "ban",
@ -56,7 +56,7 @@ var inputs = [
"raw", "raw",
"topic", "topic",
"list", "list",
"whois" "whois",
].reduce(function(plugins, name) { ].reduce(function(plugins, name) {
var path = "./plugins/inputs/" + name; var path = "./plugins/inputs/" + name;
var plugin = require(path); var plugin = require(path);
@ -78,7 +78,7 @@ function Client(manager, name, config) {
name: name, name: name,
networks: [], networks: [],
sockets: manager.sockets, sockets: manager.sockets,
manager: manager manager: manager,
}); });
var client = this; var client = this;
@ -130,7 +130,7 @@ Client.prototype.find = function(channelId) {
if (network && chan) { if (network && chan) {
return { return {
network: network, network: network,
chan: chan chan: chan,
}; };
} }
@ -171,7 +171,7 @@ Client.prototype.connect = function(args) {
.split(/\s+/g) .split(/\s+/g)
.map(function(chan) { .map(function(chan) {
return new Chan({ return new Chan({
name: chan name: chan,
}); });
}); });
} }
@ -196,7 +196,7 @@ Client.prototype.connect = function(args) {
client.networks.push(network); client.networks.push(network);
client.emit("network", { client.emit("network", {
networks: [network] networks: [network],
}); });
if (config.lockNetwork) { if (config.lockNetwork) {
@ -204,7 +204,7 @@ Client.prototype.connect = function(args) {
if (args.host && args.host.length > 0 && args.host !== config.defaults.host) { if (args.host && args.host.length > 0 && args.host !== config.defaults.host) {
network.channels[0].pushMessage(client, new Msg({ network.channels[0].pushMessage(client, new Msg({
type: Msg.Type.ERROR, type: Msg.Type.ERROR,
text: "Hostname you specified is not allowed." text: "Hostname you specified is not allowed.",
}), true); }), true);
return; return;
} }
@ -217,7 +217,7 @@ Client.prototype.connect = function(args) {
if (network.host.length === 0) { if (network.host.length === 0) {
network.channels[0].pushMessage(client, new Msg({ network.channels[0].pushMessage(client, new Msg({
type: Msg.Type.ERROR, type: Msg.Type.ERROR,
text: "You must specify a hostname to connect." text: "You must specify a hostname to connect.",
}), true); }), true);
return; return;
} }
@ -235,7 +235,7 @@ Client.prototype.connect = function(args) {
password: config.webirc[network.host], password: config.webirc[network.host],
username: pkg.name, username: pkg.name,
address: args.ip, address: args.ip,
hostname: args.hostname hostname: args.hostname,
}; };
} }
} else { } else {
@ -270,7 +270,7 @@ Client.prototype.connect = function(args) {
var path = "./plugins/irc-events/" + plugin; var path = "./plugins/irc-events/" + plugin;
require(path).apply(client, [ require(path).apply(client, [
network.irc, network.irc,
network network,
]); ]);
}); });
@ -311,7 +311,7 @@ Client.prototype.updateSession = function(token, ip, request) {
}); });
client.manager.updateUser(client.name, { client.manager.updateUser(client.name, {
sessions: client.config.sessions sessions: client.config.sessions,
}); });
}; };
@ -319,7 +319,7 @@ Client.prototype.setPassword = function(hash, callback) {
var client = this; var client = this;
client.manager.updateUser(client.name, { client.manager.updateUser(client.name, {
password: hash password: hash,
}, function(err) { }, function(err) {
if (err) { if (err) {
return callback(false); return callback(false);
@ -355,7 +355,7 @@ Client.prototype.inputLine = function(data) {
if (target.chan.type === Chan.Type.LOBBY) { if (target.chan.type === Chan.Type.LOBBY) {
target.chan.pushMessage(this, new Msg({ target.chan.pushMessage(this, new Msg({
type: Msg.Type.ERROR, type: Msg.Type.ERROR,
text: "Messages can not be sent to lobbies." text: "Messages can not be sent to lobbies.",
})); }));
return; return;
} }
@ -384,7 +384,7 @@ Client.prototype.inputLine = function(data) {
if (!connected) { if (!connected) {
target.chan.pushMessage(this, new Msg({ target.chan.pushMessage(this, new Msg({
type: Msg.Type.ERROR, type: Msg.Type.ERROR,
text: "You are not connected to the IRC network, unable to send your command." text: "You are not connected to the IRC network, unable to send your command.",
})); }));
} }
}; };
@ -415,7 +415,7 @@ Client.prototype.more = function(data) {
client.emit("more", { client.emit("more", {
chan: chan.id, chan: chan.id,
messages: messages messages: messages,
}); });
}; };
@ -483,7 +483,7 @@ Client.prototype.names = function(data) {
client.emit("names", { client.emit("names", {
id: target.chan.id, id: target.chan.id,
users: target.chan.users users: target.chan.users,
}); });
}; };
@ -530,7 +530,7 @@ Client.prototype.clientAttach = function(socketId, token) {
client.attachedClients[socketId] = { client.attachedClients[socketId] = {
token: token, token: token,
openChannel: client.lastActiveChannel openChannel: client.lastActiveChannel,
}; };
// Update old networks to store ip and hostmask // Update old networks to store ip and hostmask
@ -583,15 +583,15 @@ Client.prototype.registerPushSubscription = function(session, subscription, noSa
endpoint: subscription.endpoint, endpoint: subscription.endpoint,
keys: { keys: {
p256dh: subscription.keys.p256dh, p256dh: subscription.keys.p256dh,
auth: subscription.keys.auth auth: subscription.keys.auth,
} },
}; };
session.pushSubscription = data; session.pushSubscription = data;
if (!noSave) { if (!noSave) {
this.manager.updateUser(this.name, { this.manager.updateUser(this.name, {
sessions: this.config.sessions sessions: this.config.sessions,
}); });
} }
@ -601,7 +601,7 @@ Client.prototype.registerPushSubscription = function(session, subscription, noSa
Client.prototype.unregisterPushSubscription = function(token) { Client.prototype.unregisterPushSubscription = function(token) {
this.config.sessions[token].pushSubscription = null; this.config.sessions[token].pushSubscription = null;
this.manager.updateUser(this.name, { this.manager.updateUser(this.name, {
sessions: this.config.sessions sessions: this.config.sessions,
}); });
}; };

View file

@ -36,7 +36,7 @@ program
log.prompt({ log.prompt({
text: "Enter password:", text: "Enter password:",
silent: true silent: true,
}, function(err, password) { }, function(err, password) {
if (!password) { if (!password) {
log.error("Password cannot be empty."); log.error("Password cannot be empty.");
@ -45,7 +45,7 @@ program
if (!err) { if (!err) {
log.prompt({ log.prompt({
text: "Save logs to disk?", text: "Save logs to disk?",
default: "yes" default: "yes",
}, function(err2, enableLog) { }, function(err2, enableLog) {
if (!err2) { if (!err2) {
add( add(

View file

@ -24,7 +24,7 @@ program
log.info("Retrieving information about the package..."); log.info("Retrieving information about the package...");
packageJson(packageName, { packageJson(packageName, {
fullMetadata: true fullMetadata: true,
}).then((json) => { }).then((json) => {
if (!("thelounge" in json)) { if (!("thelounge" in json)) {
log.error(`${colors.red(packageName)} does not have The Lounge metadata.`); log.error(`${colors.red(packageName)} does not have The Lounge metadata.`);
@ -57,10 +57,10 @@ program
"--no-package-lock", "--no-package-lock",
"--prefix", "--prefix",
packagesParent, packagesParent,
packageName packageName,
], ],
{ {
stdio: "inherit" stdio: "inherit",
} }
); );

View file

@ -32,7 +32,7 @@ program
var user = require(file); var user = require(file);
log.prompt({ log.prompt({
text: "Enter new password:", text: "Enter new password:",
silent: true silent: true,
}, function(err, password) { }, function(err, password) {
if (err) { if (err) {
return; return;

View file

@ -28,7 +28,7 @@ function Chan(attr) {
firstUnread: 0, firstUnread: 0,
unread: 0, unread: 0,
highlight: 0, highlight: 0,
users: [] users: [],
}); });
} }
@ -39,7 +39,7 @@ Chan.prototype.destroy = function() {
Chan.prototype.pushMessage = function(client, msg, increasesUnread) { Chan.prototype.pushMessage = function(client, msg, increasesUnread) {
var obj = { var obj = {
chan: this.id, chan: this.id,
msg: msg msg: msg,
}; };
// If this channel is open in any of the clients, do not increase unread counter // If this channel is open in any of the clients, do not increase unread counter

View file

@ -12,7 +12,7 @@ class Msg {
previews: [], previews: [],
text: "", text: "",
type: Msg.Type.MESSAGE, type: Msg.Type.MESSAGE,
self: false self: false,
}); });
if (this.time > 0) { if (this.time > 0) {
@ -47,7 +47,7 @@ Msg.Type = {
TOPIC: "topic", TOPIC: "topic",
TOPIC_SET_BY: "topic_set_by", TOPIC_SET_BY: "topic_set_by",
WHOIS: "whois", WHOIS: "whois",
BANLIST: "ban_list" BANLIST: "ban_list",
}; };
module.exports = Msg; module.exports = Msg;

View file

@ -37,7 +37,7 @@ function Network(attr) {
this.channels.unshift( this.channels.unshift(
new Chan({ new Chan({
name: this.name, name: this.name,
type: Chan.Type.LOBBY type: Chan.Type.LOBBY,
}) })
); );
} }
@ -86,7 +86,7 @@ Network.prototype.export = function() {
"realname", "realname",
"commands", "commands",
"ip", "ip",
"hostname" "hostname",
]); ]);
network.channels = this.channels network.channels = this.channels

View file

@ -8,7 +8,7 @@ function ldapAuthCommon(user, bindDN, password, callback) {
const ldapclient = ldap.createClient({ const ldapclient = ldap.createClient({
url: config.ldap.url, url: config.ldap.url,
tlsOptions: config.ldap.tlsOptions tlsOptions: config.ldap.tlsOptions,
}); });
ldapclient.on("error", function(err) { ldapclient.on("error", function(err) {
@ -50,14 +50,14 @@ function advancedLdapAuth(user, password, callback) {
const ldapclient = ldap.createClient({ const ldapclient = ldap.createClient({
url: config.ldap.url, url: config.ldap.url,
tlsOptions: config.ldap.tlsOptions tlsOptions: config.ldap.tlsOptions,
}); });
const base = config.ldap.searchDN.base; const base = config.ldap.searchDN.base;
const searchOptions = { const searchOptions = {
scope: config.ldap.searchDN.scope, scope: config.ldap.searchDN.scope,
filter: `(&(${config.ldap.primaryKey}=${userDN})${config.ldap.searchDN.filter})`, filter: `(&(${config.ldap.primaryKey}=${userDN})${config.ldap.searchDN.filter})`,
attributes: ["dn"] attributes: ["dn"],
}; };
ldapclient.on("error", function(err) { ldapclient.on("error", function(err) {
@ -129,5 +129,5 @@ function isLdapEnabled() {
module.exports = { module.exports = {
auth: ldapAuth, auth: ldapAuth,
isEnabled: isLdapEnabled isEnabled: isLdapEnabled,
}; };

View file

@ -37,6 +37,6 @@ function localAuth(manager, client, user, password, callback) {
module.exports = { module.exports = {
auth: localAuth, auth: localAuth,
isEnabled: () => true isEnabled: () => true,
}; };

View file

@ -9,7 +9,7 @@ exports.input = function(network, chan, cmd, args) {
if (chan.type !== Chan.Type.CHANNEL && chan.type !== Chan.Type.QUERY) { if (chan.type !== Chan.Type.CHANNEL && chan.type !== Chan.Type.QUERY) {
chan.pushMessage(this, new Msg({ chan.pushMessage(this, new Msg({
type: Msg.Type.ERROR, type: Msg.Type.ERROR,
text: `${cmd} command can only be used in channels and queries.` text: `${cmd} command can only be used in channels and queries.`,
})); }));
return; return;
@ -35,7 +35,7 @@ exports.input = function(network, chan, cmd, args) {
irc.emit("action", { irc.emit("action", {
nick: irc.user.nick, nick: irc.user.nick,
target: chan.name, target: chan.name,
message: text message: text,
}); });
} }

View file

@ -6,14 +6,14 @@ var Msg = require("../../models/msg");
exports.commands = [ exports.commands = [
"ban", "ban",
"unban", "unban",
"banlist" "banlist",
]; ];
exports.input = function(network, chan, cmd, args) { exports.input = function(network, chan, cmd, args) {
if (chan.type !== Chan.Type.CHANNEL) { if (chan.type !== Chan.Type.CHANNEL) {
chan.pushMessage(this, new Msg({ chan.pushMessage(this, new Msg({
type: Msg.Type.ERROR, type: Msg.Type.ERROR,
text: `${cmd} command can only be used in channels.` text: `${cmd} command can only be used in channels.`,
})); }));
return; return;
@ -23,7 +23,7 @@ exports.input = function(network, chan, cmd, args) {
if (args.length === 0) { if (args.length === 0) {
chan.pushMessage(this, new Msg({ chan.pushMessage(this, new Msg({
type: Msg.Type.ERROR, type: Msg.Type.ERROR,
text: `Usage: /${cmd} <nick>` text: `Usage: /${cmd} <nick>`,
})); }));
return; return;

View file

@ -14,7 +14,7 @@ exports.input = function(network, chan, cmd, args) {
if (network.irc.connection.connected) { if (network.irc.connection.connected) {
chan.pushMessage(this, new Msg({ chan.pushMessage(this, new Msg({
type: Msg.Type.ERROR, type: Msg.Type.ERROR,
text: "You are already connected." text: "You are already connected.",
})); }));
return; return;
} }

View file

@ -15,7 +15,7 @@ exports.input = function(network, chan, cmd, args) {
} else { } else {
chan.pushMessage(this, new Msg({ chan.pushMessage(this, new Msg({
type: Msg.Type.ERROR, type: Msg.Type.ERROR,
text: `${cmd} command can only be used in channels or by specifying a target.` text: `${cmd} command can only be used in channels or by specifying a target.`,
})); }));
} }
}; };

View file

@ -9,7 +9,7 @@ exports.input = function(network, chan, cmd, args) {
if (chan.type !== Chan.Type.CHANNEL) { if (chan.type !== Chan.Type.CHANNEL) {
chan.pushMessage(this, new Msg({ chan.pushMessage(this, new Msg({
type: Msg.Type.ERROR, type: Msg.Type.ERROR,
text: `${cmd} command can only be used in channels.` text: `${cmd} command can only be used in channels.`,
})); }));
return; return;

View file

@ -18,7 +18,7 @@ exports.input = function(network, chan, cmd, args) {
if (chan.type !== Chan.Type.CHANNEL) { if (chan.type !== Chan.Type.CHANNEL) {
chan.pushMessage(this, new Msg({ chan.pushMessage(this, new Msg({
type: Msg.Type.ERROR, type: Msg.Type.ERROR,
text: `${cmd} command can only be used in channels.` text: `${cmd} command can only be used in channels.`,
})); }));
return; return;
@ -27,7 +27,7 @@ exports.input = function(network, chan, cmd, args) {
if (args.length === 0) { if (args.length === 0) {
chan.pushMessage(this, new Msg({ chan.pushMessage(this, new Msg({
type: Msg.Type.ERROR, type: Msg.Type.ERROR,
text: `Usage: /${cmd} <nick> [...nick]` text: `Usage: /${cmd} <nick> [...nick]`,
})); }));
return; return;
@ -39,7 +39,7 @@ exports.input = function(network, chan, cmd, args) {
voice: "+v", voice: "+v",
deop: "-o", deop: "-o",
dehop: "-h", dehop: "-h",
devoice: "-v" devoice: "-v",
}[cmd]; }[cmd];
args.forEach(function(target) { args.forEach(function(target) {

View file

@ -24,7 +24,7 @@ exports.input = function(network, chan, cmd, args) {
irc.emit("privmsg", { irc.emit("privmsg", {
nick: irc.user.nick, nick: irc.user.nick,
target: channel.name, target: channel.name,
message: msg message: msg,
}); });
} }
} }

View file

@ -9,7 +9,7 @@ exports.input = function(network, chan, cmd, args) {
if (args.length === 0) { if (args.length === 0) {
chan.pushMessage(this, new Msg({ chan.pushMessage(this, new Msg({
type: Msg.Type.ERROR, type: Msg.Type.ERROR,
text: "Usage: /nick <your new nick>" text: "Usage: /nick <your new nick>",
})); }));
return; return;
} }
@ -17,7 +17,7 @@ exports.input = function(network, chan, cmd, args) {
if (args.length !== 1) { if (args.length !== 1) {
chan.pushMessage(this, new Msg({ chan.pushMessage(this, new Msg({
type: Msg.Type.ERROR, type: Msg.Type.ERROR,
text: "Nicknames may not contain spaces." text: "Nicknames may not contain spaces.",
})); }));
return; return;
} }
@ -33,7 +33,7 @@ exports.input = function(network, chan, cmd, args) {
this.emit("nick", { this.emit("nick", {
network: network.id, network: network.id,
nick: newNick nick: newNick,
}); });
} }
}; };

View file

@ -21,7 +21,7 @@ exports.input = function(network, chan, cmd, args) {
irc.emit("notice", { irc.emit("notice", {
nick: irc.user.nick, nick: irc.user.nick,
target: targetChan.name, target: targetChan.name,
message: message message: message,
}); });
} }

View file

@ -22,7 +22,7 @@ exports.input = function(network, chan, cmd, args) {
if (target.type === Chan.Type.LOBBY) { if (target.type === Chan.Type.LOBBY) {
chan.pushMessage(this, new Msg({ chan.pushMessage(this, new Msg({
type: Msg.Type.ERROR, type: Msg.Type.ERROR,
text: "You can not part from networks, use /quit instead." text: "You can not part from networks, use /quit instead.",
})); }));
return; return;
} }
@ -30,7 +30,7 @@ exports.input = function(network, chan, cmd, args) {
network.channels = _.without(network.channels, target); network.channels = _.without(network.channels, target);
target.destroy(); target.destroy();
this.emit("part", { this.emit("part", {
chan: target.id chan: target.id,
}); });
if (target.type === Chan.Type.CHANNEL) { if (target.type === Chan.Type.CHANNEL) {

View file

@ -21,7 +21,7 @@ exports.input = function(network, chan, cmd, args) {
if (network.irc.network.options.CHANTYPES && network.irc.network.options.CHANTYPES.indexOf(char) !== -1) { if (network.irc.network.options.CHANTYPES && network.irc.network.options.CHANTYPES.indexOf(char) !== -1) {
chan.pushMessage(this, new Msg({ chan.pushMessage(this, new Msg({
type: Msg.Type.ERROR, type: Msg.Type.ERROR,
text: "You can not open query windows for channels, use /join instead." text: "You can not open query windows for channels, use /join instead.",
})); }));
return; return;
} }
@ -30,7 +30,7 @@ exports.input = function(network, chan, cmd, args) {
if (network.irc.network.options.PREFIX[i].symbol === char) { if (network.irc.network.options.PREFIX[i].symbol === char) {
chan.pushMessage(this, new Msg({ chan.pushMessage(this, new Msg({
type: Msg.Type.ERROR, type: Msg.Type.ERROR,
text: "You can not open query windows for names starting with a user prefix." text: "You can not open query windows for names starting with a user prefix.",
})); }));
return; return;
} }
@ -38,11 +38,11 @@ exports.input = function(network, chan, cmd, args) {
var newChan = new Chan({ var newChan = new Chan({
type: Chan.Type.QUERY, type: Chan.Type.QUERY,
name: target name: target,
}); });
network.channels.push(newChan); network.channels.push(newChan);
this.emit("join", { this.emit("join", {
network: network.id, network: network.id,
chan: newChan chan: newChan,
}); });
}; };

View file

@ -13,7 +13,7 @@ exports.input = function(network, chan, cmd, args) {
network.destroy(); network.destroy();
client.save(); client.save();
client.emit("quit", { client.emit("quit", {
network: network.id network: network.id,
}); });
if (network.irc) { if (network.irc) {

View file

@ -9,7 +9,7 @@ exports.input = function(network, chan) {
if (chan.type !== Chan.Type.CHANNEL) { if (chan.type !== Chan.Type.CHANNEL) {
chan.pushMessage(this, new Msg({ chan.pushMessage(this, new Msg({
type: Msg.Type.ERROR, type: Msg.Type.ERROR,
text: "You can only rejoin channels." text: "You can only rejoin channels.",
})); }));
return; return;
} }

View file

@ -9,7 +9,7 @@ exports.input = function(network, chan, cmd, args) {
if (chan.type !== Chan.Type.CHANNEL) { if (chan.type !== Chan.Type.CHANNEL) {
chan.pushMessage(this, new Msg({ chan.pushMessage(this, new Msg({
type: Msg.Type.ERROR, type: Msg.Type.ERROR,
text: `${cmd} command can only be used in channels.` text: `${cmd} command can only be used in channels.`,
})); }));
return; return;

View file

@ -20,7 +20,7 @@ module.exports = function(irc, network) {
text: away || "", text: away || "",
time: data.time, time: data.time,
from: data.nick, from: data.nick,
mode: user.mode mode: user.mode,
}); });
chan.pushMessage(client, msg); chan.pushMessage(client, msg);

View file

@ -13,7 +13,7 @@ module.exports = function(irc, network) {
const msg = new Msg({ const msg = new Msg({
time: Date.now(), time: Date.now(),
type: Msg.Type.ERROR, type: Msg.Type.ERROR,
text: "Banlist empty" text: "Banlist empty",
}); });
network.getChannel(channel).pushMessage(client, msg, true); network.getChannel(channel).pushMessage(client, msg, true);
return; return;
@ -24,12 +24,12 @@ module.exports = function(irc, network) {
if (typeof chan === "undefined") { if (typeof chan === "undefined") {
chan = new Chan({ chan = new Chan({
type: Chan.Type.SPECIAL, type: Chan.Type.SPECIAL,
name: chanName name: chanName,
}); });
network.channels.push(chan); network.channels.push(chan);
client.emit("join", { client.emit("join", {
network: network.id, network: network.id,
chan: chan chan: chan,
}); });
} }
@ -39,8 +39,8 @@ module.exports = function(irc, network) {
bans: bans.map((data) => ({ bans: bans.map((data) => ({
hostmask: data.banned, hostmask: data.banned,
banned_by: data.banned_by, banned_by: data.banned_by,
banned_at: data.banned_at * 1000 banned_at: data.banned_at * 1000,
})) })),
}), }),
true true
); );

View file

@ -9,13 +9,13 @@ module.exports = function(irc, network) {
var client = this; var client = this;
network.channels[0].pushMessage(client, new Msg({ network.channels[0].pushMessage(client, new Msg({
text: "Network created, connecting to " + network.host + ":" + network.port + "..." text: "Network created, connecting to " + network.host + ":" + network.port + "...",
}), true); }), true);
irc.on("registered", function() { irc.on("registered", function() {
if (network.irc.network.cap.enabled.length > 0) { if (network.irc.network.cap.enabled.length > 0) {
network.channels[0].pushMessage(client, new Msg({ network.channels[0].pushMessage(client, new Msg({
text: "Enabled capabilities: " + network.irc.network.cap.enabled.join(", ") text: "Enabled capabilities: " + network.irc.network.cap.enabled.join(", "),
}), true); }), true);
} }
@ -34,7 +34,7 @@ module.exports = function(irc, network) {
setTimeout(function() { setTimeout(function() {
client.input({ client.input({
target: network.channels[0].id, target: network.channels[0].id,
text: cmd text: cmd,
}); });
}, delay); }, delay);
delay += 1000; delay += 1000;
@ -60,13 +60,13 @@ module.exports = function(irc, network) {
}); });
network.channels[0].pushMessage(client, new Msg({ network.channels[0].pushMessage(client, new Msg({
text: "Connected to the network." text: "Connected to the network.",
}), true); }), true);
}); });
irc.on("close", function() { irc.on("close", function() {
network.channels[0].pushMessage(client, new Msg({ network.channels[0].pushMessage(client, new Msg({
text: "Disconnected from the network, and will not reconnect. Use /connect to reconnect again." text: "Disconnected from the network, and will not reconnect. Use /connect to reconnect again.",
}), true); }), true);
}); });
@ -95,7 +95,7 @@ module.exports = function(irc, network) {
from: message.from_server ? "«" : "»", from: message.from_server ? "«" : "»",
self: !message.from_server, self: !message.from_server,
type: "raw", type: "raw",
text: message.line text: message.line,
}), true); }), true);
}); });
} }
@ -103,19 +103,19 @@ module.exports = function(irc, network) {
irc.on("socket error", function(err) { irc.on("socket error", function(err) {
network.channels[0].pushMessage(client, new Msg({ network.channels[0].pushMessage(client, new Msg({
type: Msg.Type.ERROR, type: Msg.Type.ERROR,
text: "Socket error: " + err text: "Socket error: " + err,
}), true); }), true);
}); });
irc.on("reconnecting", function(data) { irc.on("reconnecting", function(data) {
network.channels[0].pushMessage(client, new Msg({ network.channels[0].pushMessage(client, new Msg({
text: "Disconnected from the network. Reconnecting in " + Math.round(data.wait / 1000) + " seconds… (Attempt " + data.attempt + " of " + data.max_retries + ")" text: "Disconnected from the network. Reconnecting in " + Math.round(data.wait / 1000) + " seconds… (Attempt " + data.attempt + " of " + data.max_retries + ")",
}), true); }), true);
}); });
irc.on("ping timeout", function() { irc.on("ping timeout", function() {
network.channels[0].pushMessage(client, new Msg({ network.channels[0].pushMessage(client, new Msg({
text: "Ping timeout, disconnecting…" text: "Ping timeout, disconnecting…",
}), true); }), true);
}); });
@ -135,7 +135,7 @@ module.exports = function(irc, network) {
client.emit("network_changed", { client.emit("network_changed", {
network: network.id, network: network.id,
serverOptions: network.serverOptions serverOptions: network.serverOptions,
}); });
}); });
}; };

View file

@ -16,7 +16,7 @@ module.exports = function(irc, network) {
time: data.time, time: data.time,
from: data.nick, from: data.nick,
ctcpType: data.type, ctcpType: data.type,
ctcpMessage: data.message ctcpMessage: data.message,
}); });
chan.pushMessage(client, msg); chan.pushMessage(client, msg);
}); });

View file

@ -33,7 +33,7 @@ module.exports = function(irc, network) {
client.emit("nick", { client.emit("nick", {
network: network.id, network: network.id,
nick: irc.user.nick nick: irc.user.nick,
}); });
}); });
@ -52,7 +52,7 @@ module.exports = function(irc, network) {
client.emit("nick", { client.emit("nick", {
network: network.id, network: network.id,
nick: irc.user.nick nick: irc.user.nick,
}); });
}); });
}; };

View file

@ -17,7 +17,7 @@ module.exports = function(irc, network) {
invited: data.invited, invited: data.invited,
channel: data.channel, channel: data.channel,
highlight: true, highlight: true,
invitedYou: data.invited === irc.user.nick invitedYou: data.invited === irc.user.nick,
}); });
chan.pushMessage(client, msg); chan.pushMessage(client, msg);
}); });

View file

@ -10,13 +10,13 @@ module.exports = function(irc, network) {
var chan = network.getChannel(data.channel); var chan = network.getChannel(data.channel);
if (typeof chan === "undefined") { if (typeof chan === "undefined") {
chan = new Chan({ chan = new Chan({
name: data.channel name: data.channel,
}); });
network.channels.push(chan); network.channels.push(chan);
client.save(); client.save();
client.emit("join", { client.emit("join", {
network: network.id, network: network.id,
chan: chan chan: chan,
}); });
// Request channels' modes // Request channels' modes
@ -25,14 +25,14 @@ module.exports = function(irc, network) {
chan.users.push(new User({nick: data.nick})); chan.users.push(new User({nick: data.nick}));
chan.sortUsers(irc); chan.sortUsers(irc);
client.emit("users", { client.emit("users", {
chan: chan.id chan: chan.id,
}); });
var msg = new Msg({ var msg = new Msg({
time: data.time, time: data.time,
from: data.nick, from: data.nick,
hostmask: data.ident + "@" + data.hostname, hostmask: data.ident + "@" + data.hostname,
type: Msg.Type.JOIN, type: Msg.Type.JOIN,
self: data.nick === irc.user.nick self: data.nick === irc.user.nick,
}); });
chan.pushMessage(client, msg); chan.pushMessage(client, msg);
}); });

View file

@ -21,7 +21,7 @@ module.exports = function(irc, network) {
} }
client.emit("users", { client.emit("users", {
chan: chan.id chan: chan.id,
}); });
var msg = new Msg({ var msg = new Msg({
@ -31,7 +31,7 @@ module.exports = function(irc, network) {
target: target, target: target,
text: data.message || "", text: data.message || "",
highlight: data.kicked === irc.user.nick, highlight: data.kicked === irc.user.nick,
self: data.nick === irc.user.nick self: data.nick === irc.user.nick,
}); });
chan.pushMessage(client, msg); chan.pushMessage(client, msg);
}); });

View file

@ -136,7 +136,7 @@ function emitPreview(client, msg, preview) {
client.emit("msg:preview", { client.emit("msg:preview", {
id: msg.id, id: msg.id,
preview: preview preview: preview,
}); });
} }
@ -148,8 +148,8 @@ function fetch(uri, cb) {
maxRedirects: 5, maxRedirects: 5,
timeout: 5000, timeout: 5000,
headers: { headers: {
"User-Agent": "Mozilla/5.0 (compatible; The Lounge IRC Client; +https://github.com/thelounge/lounge)" "User-Agent": "Mozilla/5.0 (compatible; The Lounge IRC Client; +https://github.com/thelounge/lounge)",
} },
}); });
} catch (e) { } catch (e) {
return cb(null); return cb(null);
@ -200,7 +200,7 @@ function fetch(uri, cb) {
cb({ cb({
data: Buffer.concat(buffers, length), data: Buffer.concat(buffers, length),
type: type, type: type,
size: size size: size,
}); });
}); });
} }

View file

@ -12,7 +12,7 @@ module.exports = function(irc, network) {
updateListStatus(new Msg({ updateListStatus(new Msg({
text: "Loading channel list, this can take a moment...", text: "Loading channel list, this can take a moment...",
type: "channel_list_loading" type: "channel_list_loading",
})); }));
}); });
@ -25,13 +25,13 @@ module.exports = function(irc, network) {
type: "channel_list", type: "channel_list",
channels: network.chanCache.sort(function(a, b) { channels: network.chanCache.sort(function(a, b) {
return b.num_users - a.num_users; return b.num_users - a.num_users;
}).slice(0, MAX_CHANS) }).slice(0, MAX_CHANS),
})); }));
if (network.chanCache.length > MAX_CHANS) { if (network.chanCache.length > MAX_CHANS) {
updateListStatus(new Msg({ updateListStatus(new Msg({
type: "channel_list_truncated", type: "channel_list_truncated",
text: "Channel list is too large: truncated to " + MAX_CHANS + " channels." text: "Channel list is too large: truncated to " + MAX_CHANS + " channels.",
})); }));
} }
@ -43,18 +43,18 @@ module.exports = function(irc, network) {
if (typeof chan === "undefined") { if (typeof chan === "undefined") {
chan = new Chan({ chan = new Chan({
type: Chan.Type.SPECIAL, type: Chan.Type.SPECIAL,
name: "Channel List" name: "Channel List",
}); });
network.channels.push(chan); network.channels.push(chan);
client.emit("join", { client.emit("join", {
network: network.id, network: network.id,
chan: chan chan: chan,
}); });
} }
client.emit("msg", { client.emit("msg", {
chan: chan.id, chan: chan.id,
msg: msg msg: msg,
}); });
} }
}; };

View file

@ -59,12 +59,12 @@ module.exports = function(irc, network) {
} else { } else {
chan = new Chan({ chan = new Chan({
type: Chan.Type.QUERY, type: Chan.Type.QUERY,
name: target name: target,
}); });
network.channels.push(chan); network.channels.push(chan);
client.emit("join", { client.emit("join", {
network: network.id, network: network.id,
chan: chan chan: chan,
}); });
} }
} }
@ -94,7 +94,7 @@ module.exports = function(irc, network) {
from: data.nick, from: data.nick,
text: data.message, text: data.message,
self: self, self: self,
highlight: highlight highlight: highlight,
}); });
// No prefetch URLs unless are simple MESSAGE or ACTION types // No prefetch URLs unless are simple MESSAGE or ACTION types
@ -128,7 +128,7 @@ module.exports = function(irc, network) {
chanId: chan.id, chanId: chan.id,
timestamp: data.time || Date.now(), timestamp: data.time || Date.now(),
title: title, title: title,
body: body body: body,
}, true); }, true);
} }
} }

View file

@ -73,7 +73,7 @@ module.exports = function(irc, network) {
mode: (targetChan.type !== Chan.Type.LOBBY && targetChan.getMode(data.nick)) || "", mode: (targetChan.type !== Chan.Type.LOBBY && targetChan.getMode(data.nick)) || "",
from: data.nick, from: data.nick,
text: text, text: text,
self: data.nick === irc.user.nick self: data.nick === irc.user.nick,
}); });
targetChan.pushMessage(client, msg); targetChan.pushMessage(client, msg);
@ -118,7 +118,7 @@ module.exports = function(irc, network) {
targetChan.sortUsers(irc); targetChan.sortUsers(irc);
client.emit("users", { client.emit("users", {
chan: targetChan.id chan: targetChan.id,
}); });
} }
}); });

View file

@ -11,7 +11,7 @@ module.exports = function(irc, network) {
data.motd.split("\n").forEach((text) => { data.motd.split("\n").forEach((text) => {
var msg = new Msg({ var msg = new Msg({
type: Msg.Type.MOTD, type: Msg.Type.MOTD,
text: text text: text,
}); });
lobby.pushMessage(client, msg); lobby.pushMessage(client, msg);
}); });
@ -20,7 +20,7 @@ module.exports = function(irc, network) {
if (data.error) { if (data.error) {
var msg = new Msg({ var msg = new Msg({
type: Msg.Type.MOTD, type: Msg.Type.MOTD,
text: data.error text: data.error,
}); });
lobby.pushMessage(client, msg); lobby.pushMessage(client, msg);
} }

View file

@ -38,7 +38,7 @@ module.exports = function(irc, network) {
chan.sortUsers(irc); chan.sortUsers(irc);
client.emit("users", { client.emit("users", {
chan: chan.id chan: chan.id,
}); });
}); });
}; };

View file

@ -19,7 +19,7 @@ module.exports = function(irc, network) {
client.save(); client.save();
client.emit("nick", { client.emit("nick", {
network: network.id, network: network.id,
nick: data.new_nick nick: data.new_nick,
}); });
} }
@ -31,7 +31,7 @@ module.exports = function(irc, network) {
user.nick = data.new_nick; user.nick = data.new_nick;
chan.sortUsers(irc); chan.sortUsers(irc);
client.emit("users", { client.emit("users", {
chan: chan.id chan: chan.id,
}); });
msg = new Msg({ msg = new Msg({
time: data.time, time: data.time,
@ -39,7 +39,7 @@ module.exports = function(irc, network) {
type: Msg.Type.NICK, type: Msg.Type.NICK,
mode: chan.getMode(data.new_nick), mode: chan.getMode(data.new_nick),
new_nick: data.new_nick, new_nick: data.new_nick,
self: self self: self,
}); });
chan.pushMessage(client, msg); chan.pushMessage(client, msg);
}); });

View file

@ -16,13 +16,13 @@ module.exports = function(irc, network) {
chan.destroy(); chan.destroy();
client.save(); client.save();
client.emit("part", { client.emit("part", {
chan: chan.id chan: chan.id,
}); });
} else { } else {
const user = chan.findUser(from); const user = chan.findUser(from);
chan.users = _.without(chan.users, user); chan.users = _.without(chan.users, user);
client.emit("users", { client.emit("users", {
chan: chan.id chan: chan.id,
}); });
var msg = new Msg({ var msg = new Msg({
type: Msg.Type.PART, type: Msg.Type.PART,
@ -30,7 +30,7 @@ module.exports = function(irc, network) {
mode: (user && user.mode) || "", mode: (user && user.mode) || "",
text: data.message || "", text: data.message || "",
hostmask: data.ident + "@" + data.hostname, hostmask: data.ident + "@" + data.hostname,
from: from from: from,
}); });
chan.pushMessage(client, msg); chan.pushMessage(client, msg);
} }

View file

@ -13,7 +13,7 @@ module.exports = function(irc, network) {
} }
chan.users = _.without(chan.users, user); chan.users = _.without(chan.users, user);
client.emit("users", { client.emit("users", {
chan: chan.id chan: chan.id,
}); });
var msg = new Msg({ var msg = new Msg({
time: data.time, time: data.time,
@ -21,7 +21,7 @@ module.exports = function(irc, network) {
mode: user.mode || "", mode: user.mode || "",
text: data.message || "", text: data.message || "",
hostmask: data.ident + "@" + data.hostname, hostmask: data.ident + "@" + data.hostname,
from: data.nick from: data.nick,
}); });
chan.pushMessage(client, msg); chan.pushMessage(client, msg);
}); });

View file

@ -16,14 +16,14 @@ module.exports = function(irc, network) {
mode: (data.nick && chan.getMode(data.nick)) || "", mode: (data.nick && chan.getMode(data.nick)) || "",
from: data.nick, from: data.nick,
text: data.topic, text: data.topic,
self: data.nick === irc.user.nick self: data.nick === irc.user.nick,
}); });
chan.pushMessage(client, msg); chan.pushMessage(client, msg);
chan.topic = data.topic; chan.topic = data.topic;
client.emit("topic", { client.emit("topic", {
chan: chan.id, chan: chan.id,
topic: chan.topic topic: chan.topic,
}); });
}); });
@ -38,7 +38,7 @@ module.exports = function(irc, network) {
mode: chan.getMode(data.nick), mode: chan.getMode(data.nick),
nick: data.nick, nick: data.nick,
when: new Date(data.when * 1000), when: new Date(data.when * 1000),
self: data.nick === irc.user.nick self: data.nick === irc.user.nick,
}); });
chan.pushMessage(client, msg); chan.pushMessage(client, msg);
}); });

View file

@ -14,7 +14,7 @@ module.exports = function(irc, network) {
network.channels[0].pushMessage(client, new Msg({ network.channels[0].pushMessage(client, new Msg({
type: Msg.Type.UNHANDLED, type: Msg.Type.UNHANDLED,
command: command.command, command: command.command,
params: command.params params: command.params,
}), true); }), true);
}); });
}; };

View file

@ -9,13 +9,13 @@ module.exports = function(irc, network) {
var lobby = network.channels[0]; var lobby = network.channels[0];
var msg = new Msg({ var msg = new Msg({
text: "You're now known as " + data.nick text: "You're now known as " + data.nick,
}); });
lobby.pushMessage(client, msg); lobby.pushMessage(client, msg);
client.save(); client.save();
client.emit("nick", { client.emit("nick", {
network: network.id, network: network.id,
nick: data.nick nick: data.nick,
}); });
}); });
}; };

View file

@ -10,13 +10,13 @@ module.exports = function(irc, network) {
if (typeof chan === "undefined") { if (typeof chan === "undefined") {
chan = new Chan({ chan = new Chan({
type: Chan.Type.QUERY, type: Chan.Type.QUERY,
name: data.nick name: data.nick,
}); });
network.channels.push(chan); network.channels.push(chan);
client.emit("join", { client.emit("join", {
shouldOpen: true, shouldOpen: true,
network: network.id, network: network.id,
chan: chan chan: chan,
}); });
} }
@ -24,7 +24,7 @@ module.exports = function(irc, network) {
if (data.error) { if (data.error) {
msg = new Msg({ msg = new Msg({
type: Msg.Type.ERROR, type: Msg.Type.ERROR,
text: "No such nick: " + data.nick text: "No such nick: " + data.nick,
}); });
} else { } else {
// Absolute datetime in milliseconds since nick is idle // Absolute datetime in milliseconds since nick is idle
@ -32,7 +32,7 @@ module.exports = function(irc, network) {
msg = new Msg({ msg = new Msg({
type: Msg.Type.WHOIS, type: Msg.Type.WHOIS,
whois: data whois: data,
}); });
} }

View file

@ -9,7 +9,7 @@ const themes = new Map();
module.exports = { module.exports = {
getAll: getAll, getAll: getAll,
getFilename: getFilename getFilename: getFilename,
}; };
fs.readdir(path.join(__dirname, "..", "..", "public", "themes"), (err, builtInThemes) => { fs.readdir(path.join(__dirname, "..", "..", "public", "themes"), (err, builtInThemes) => {
@ -50,7 +50,7 @@ function makeLocalThemeObject(css) {
return { return {
displayName: themeName.charAt(0).toUpperCase() + themeName.slice(1), displayName: themeName.charAt(0).toUpperCase() + themeName.slice(1),
filename: path.join(__dirname, "..", "..", "public", "themes", `${themeName}.css`), filename: path.join(__dirname, "..", "..", "public", "themes", `${themeName}.css`),
name: themeName name: themeName,
}; };
} }
@ -80,6 +80,6 @@ function makePackageThemeObject(moduleName) {
return { return {
displayName: displayName, displayName: displayName,
filename: filename, filename: filename,
name: moduleName name: moduleName,
}; };
} }

View file

@ -49,8 +49,8 @@ module.exports = function() {
.engine("html", expressHandlebars({ .engine("html", expressHandlebars({
extname: ".html", extname: ".html",
helpers: { helpers: {
tojson: (c) => JSON.stringify(c) tojson: (c) => JSON.stringify(c),
} },
})) }))
.set("view engine", "html") .set("view engine", "html")
.set("views", path.join(__dirname, "..", "public")); .set("views", path.join(__dirname, "..", "public"));
@ -98,7 +98,7 @@ module.exports = function() {
server = server.createServer({ server = server.createServer({
key: fs.readFileSync(keyPath), key: fs.readFileSync(keyPath),
cert: fs.readFileSync(certPath), cert: fs.readFileSync(certPath),
ca: caPath ? fs.readFileSync(caPath) : undefined ca: caPath ? fs.readFileSync(caPath) : undefined,
}, app); }, app);
} }
@ -131,7 +131,7 @@ module.exports = function() {
const sockets = io(server, { const sockets = io(server, {
serveClient: false, serveClient: false,
transports: config.transports transports: config.transports,
}); });
sockets.on("connect", (socket) => { sockets.on("connect", (socket) => {
@ -276,13 +276,13 @@ function initializeClient(socket, client, token, lastMessage) {
var p2 = data.verify_password; var p2 = data.verify_password;
if (typeof p1 === "undefined" || p1 === "") { if (typeof p1 === "undefined" || p1 === "") {
socket.emit("change-password", { socket.emit("change-password", {
error: "Please enter a new password" error: "Please enter a new password",
}); });
return; return;
} }
if (p1 !== p2) { if (p1 !== p2) {
socket.emit("change-password", { socket.emit("change-password", {
error: "Both new password fields must match" error: "Both new password fields must match",
}); });
return; return;
} }
@ -292,7 +292,7 @@ function initializeClient(socket, client, token, lastMessage) {
.then((matching) => { .then((matching) => {
if (!matching) { if (!matching) {
socket.emit("change-password", { socket.emit("change-password", {
error: "The current password field does not match your account password" error: "The current password field does not match your account password",
}); });
return; return;
} }
@ -368,7 +368,7 @@ function initializeClient(socket, client, token, lastMessage) {
type: "notification", type: "notification",
timestamp: Date.now(), timestamp: Date.now(),
title: "The Lounge", title: "The Lounge",
body: "🚀 Push notifications have been enabled" body: "🚀 Push notifications have been enabled",
}); });
} }
}); });
@ -409,7 +409,7 @@ function initializeClient(socket, client, token, lastMessage) {
delete client.config.sessions[tokenToSignOut]; delete client.config.sessions[tokenToSignOut];
client.manager.updateUser(client.name, { client.manager.updateUser(client.name, {
sessions: client.config.sessions sessions: client.config.sessions,
}); });
_.map(client.attachedClients, (attachedClient, socketId) => { _.map(client.attachedClients, (attachedClient, socketId) => {
@ -450,7 +450,7 @@ function initializeClient(socket, client, token, lastMessage) {
pushSubscription: client.config.sessions[token], pushSubscription: client.config.sessions[token],
active: client.lastActiveChannel, active: client.lastActiveChannel,
networks: networks, networks: networks,
token: tokenToSend token: tokenToSend,
}); });
}; };

View file

@ -9,7 +9,7 @@ describe("findChannels", () => {
const expected = [{ const expected = [{
channel: "#a", channel: "#a",
start: 0, start: 0,
end: 2 end: 2,
}]; }];
const actual = findChannels(input, ["#"], ["@", "+"]); const actual = findChannels(input, ["#"], ["@", "+"]);
@ -22,7 +22,7 @@ describe("findChannels", () => {
const expected = [{ const expected = [{
channel: "#äöü", channel: "#äöü",
start: 0, start: 0,
end: 4 end: 4,
}]; }];
const actual = findChannels(input, ["#"], ["@", "+"]); const actual = findChannels(input, ["#"], ["@", "+"]);
@ -35,7 +35,7 @@ describe("findChannels", () => {
const expected = [{ const expected = [{
channel: "#channel", channel: "#channel",
start: 7, start: 7,
end: 15 end: 15,
}]; }];
const actual = findChannels(input, ["#"], ["@", "+"]); const actual = findChannels(input, ["#"], ["@", "+"]);
@ -48,7 +48,7 @@ describe("findChannels", () => {
const expected = [{ const expected = [{
channel: "#chan", channel: "#chan",
start: 0, start: 0,
end: 5 end: 5,
}]; }];
const actual = findChannels(input, ["#"], ["@", "+"]); const actual = findChannels(input, ["#"], ["@", "+"]);
@ -61,7 +61,7 @@ describe("findChannels", () => {
const expected = [{ const expected = [{
channel: "#1,000", channel: "#1,000",
start: 0, start: 0,
end: 6 end: 6,
}]; }];
const actual = findChannels(input, ["#"], ["@", "+"]); const actual = findChannels(input, ["#"], ["@", "+"]);
@ -74,7 +74,7 @@ describe("findChannels", () => {
const expected = [{ const expected = [{
channel: "#a", channel: "#a",
start: 1, start: 1,
end: 3 end: 3,
}]; }];
const actual = findChannels(input, ["#"], ["@", "+"]); const actual = findChannels(input, ["#"], ["@", "+"]);
@ -87,7 +87,7 @@ describe("findChannels", () => {
const expected = [{ const expected = [{
channel: "#a", channel: "#a",
start: 4, start: 4,
end: 6 end: 6,
}]; }];
const actual = findChannels(input, ["#"], ["!", "@", "%", "+"]); const actual = findChannels(input, ["#"], ["!", "@", "%", "+"]);
@ -100,7 +100,7 @@ describe("findChannels", () => {
const expected = [{ const expected = [{
channel: "@a", channel: "@a",
start: 0, start: 0,
end: 2 end: 2,
}]; }];
const actual = findChannels(input, ["@"], ["#", "+"]); const actual = findChannels(input, ["@"], ["#", "+"]);
@ -113,7 +113,7 @@ describe("findChannels", () => {
const expected = [{ const expected = [{
channel: "##test", channel: "##test",
start: 0, start: 0,
end: 6 end: 6,
}]; }];
const actual = findChannels(input, ["#"], ["@", "+"]); const actual = findChannels(input, ["#"], ["@", "+"]);

View file

@ -22,7 +22,7 @@ describe("findLinks", () => {
const expected = [{ const expected = [{
start: 0, start: 0,
end: 24, end: 24,
link: "http://www.nooooooooooooooo.com" link: "http://www.nooooooooooooooo.com",
}]; }];
const actual = findLinks(input); const actual = findLinks(input);
@ -35,7 +35,7 @@ describe("findLinks", () => {
const expected = [{ const expected = [{
link: "https://thelounge.github.io/", link: "https://thelounge.github.io/",
start: 8, start: 8,
end: 36 end: 36,
}]; }];
const actual = findLinks(input); const actual = findLinks(input);
@ -48,7 +48,7 @@ describe("findLinks", () => {
const expected = [{ const expected = [{
link: "http://www.duckduckgo.com", link: "http://www.duckduckgo.com",
start: 4, start: 4,
end: 22 end: 22,
}]; }];
const actual = findLinks(input); const actual = findLinks(input);
@ -61,7 +61,7 @@ describe("findLinks", () => {
const expected = [{ const expected = [{
link: "https://theos.kyriasis.com/~kyrias/stats/archlinux.html", link: "https://theos.kyriasis.com/~kyrias/stats/archlinux.html",
start: 1, start: 1,
end: 56 end: 56,
}]; }];
const actual = findLinks(input); const actual = findLinks(input);
@ -74,7 +74,7 @@ describe("findLinks", () => {
const expected = [{ const expected = [{
link: "http://www.github.com", link: "http://www.github.com",
start: 2, start: 2,
end: 16 end: 16,
}]; }];
const actual = findLinks(input); const actual = findLinks(input);
@ -96,7 +96,7 @@ describe("findLinks", () => {
const expected = [{ const expected = [{
link: "http://www.www.test.com", link: "http://www.www.test.com",
start: 0, start: 0,
end: 16 end: 16,
}]; }];
const actual = findLinks(input); const actual = findLinks(input);
@ -109,11 +109,11 @@ describe("findLinks", () => {
const expected = [{ const expected = [{
start: 0, start: 0,
end: 15, end: 15,
link: "http://www.example.com" link: "http://www.example.com",
}, { }, {
end: 42, end: 42,
start: 16, start: 16,
link: "ssh://-oProxyCommand=whois" link: "ssh://-oProxyCommand=whois",
}]; }];
const actual = findLinks(input); const actual = findLinks(input);
@ -124,7 +124,7 @@ describe("findLinks", () => {
const expected2 = [{ const expected2 = [{
start: 0, start: 0,
end: 15, end: 15,
link: "http://www.example.com" link: "http://www.example.com",
}]; }];
const actual2 = findLinks(input2); const actual2 = findLinks(input2);
@ -137,11 +137,11 @@ describe("findLinks", () => {
const expected = [{ const expected = [{
start: 0, start: 0,
end: 15, end: 15,
link: "http://www.example.com" link: "http://www.example.com",
}, { }, {
start: 30, start: 30,
end: 51, end: 51,
link: "http://thelounge.chat" link: "http://thelounge.chat",
}]; }];
const actual = findLinks(input); const actual = findLinks(input);

View file

@ -8,24 +8,24 @@ describe("merge", () => {
const textParts = [{ const textParts = [{
start: 0, start: 0,
end: 10, end: 10,
flag1: true flag1: true,
}, { }, {
start: 10, start: 10,
end: 20, end: 20,
flag2: true flag2: true,
}]; }];
const styleFragments = [{ const styleFragments = [{
start: 0, start: 0,
end: 5, end: 5,
text: "01234" text: "01234",
}, { }, {
start: 5, start: 5,
end: 15, end: 15,
text: "5678901234" text: "5678901234",
}, { }, {
start: 15, start: 15,
end: 20, end: 20,
text: "56789" text: "56789",
}]; }];
const expected = [{ const expected = [{
@ -35,12 +35,12 @@ describe("merge", () => {
fragments: [{ fragments: [{
start: 0, start: 0,
end: 5, end: 5,
text: "01234" text: "01234",
}, { }, {
start: 5, start: 5,
end: 10, end: 10,
text: "56789" text: "56789",
}] }],
}, { }, {
start: 10, start: 10,
end: 20, end: 20,
@ -48,12 +48,12 @@ describe("merge", () => {
fragments: [{ fragments: [{
start: 10, start: 10,
end: 15, end: 15,
text: "01234" text: "01234",
}, { }, {
start: 15, start: 15,
end: 20, end: 20,
text: "56789" text: "56789",
}] }],
}]; }];
const actual = merge(textParts, styleFragments); const actual = merge(textParts, styleFragments);

View file

@ -18,7 +18,7 @@ describe("parseStyle", () => {
text: "textwithcontrolcodes", text: "textwithcontrolcodes",
start: 0, start: 0,
end: 20 end: 20,
}]; }];
const actual = parseStyle(input); const actual = parseStyle(input);
@ -40,7 +40,7 @@ describe("parseStyle", () => {
text: "bold", text: "bold",
start: 0, start: 0,
end: 4 end: 4,
}]; }];
const actual = parseStyle(input); const actual = parseStyle(input);
@ -62,7 +62,7 @@ describe("parseStyle", () => {
text: "yellowText", text: "yellowText",
start: 0, start: 0,
end: 10 end: 10,
}]; }];
const actual = parseStyle(input); const actual = parseStyle(input);
@ -84,7 +84,7 @@ describe("parseStyle", () => {
text: "yellowBG redText", text: "yellowBG redText",
start: 0, start: 0,
end: 16 end: 16,
}]; }];
const actual = parseStyle(input); const actual = parseStyle(input);
@ -106,7 +106,7 @@ describe("parseStyle", () => {
text: "italic", text: "italic",
start: 0, start: 0,
end: 6 end: 6,
}]; }];
const actual = parseStyle(input); const actual = parseStyle(input);
@ -128,7 +128,7 @@ describe("parseStyle", () => {
text: "test ", text: "test ",
start: 0, start: 0,
end: 5 end: 5,
}, { }, {
bold: false, bold: false,
textColor: undefined, textColor: undefined,
@ -141,7 +141,7 @@ describe("parseStyle", () => {
text: "nice ", text: "nice ",
start: 5, start: 5,
end: 10 end: 10,
}, { }, {
bold: true, bold: true,
textColor: undefined, textColor: undefined,
@ -154,7 +154,7 @@ describe("parseStyle", () => {
text: "RES006 ", text: "RES006 ",
start: 10, start: 10,
end: 17 end: 17,
}, { }, {
bold: true, bold: true,
textColor: 3, textColor: 3,
@ -167,7 +167,7 @@ describe("parseStyle", () => {
text: "colored", text: "colored",
start: 17, start: 17,
end: 24 end: 24,
}, { }, {
bold: true, bold: true,
textColor: 3, textColor: 3,
@ -180,7 +180,7 @@ describe("parseStyle", () => {
text: " background", text: " background",
start: 24, start: 24,
end: 35 end: 35,
}, { }, {
bold: false, bold: false,
textColor: undefined, textColor: undefined,
@ -193,7 +193,7 @@ describe("parseStyle", () => {
text: "?", text: "?",
start: 35, start: 35,
end: 36 end: 36,
}]; }];
const actual = parseStyle(input); const actual = parseStyle(input);
@ -215,7 +215,7 @@ describe("parseStyle", () => {
text: "bold", text: "bold",
start: 0, start: 0,
end: 4 end: 4,
}, { }, {
bold: true, bold: true,
textColor: 8, textColor: 8,
@ -228,7 +228,7 @@ describe("parseStyle", () => {
text: "yellow", text: "yellow",
start: 4, start: 4,
end: 10 end: 10,
}, { }, {
bold: false, bold: false,
textColor: 8, textColor: 8,
@ -241,7 +241,7 @@ describe("parseStyle", () => {
text: "nonBold", text: "nonBold",
start: 10, start: 10,
end: 17 end: 17,
}, { }, {
bold: false, bold: false,
textColor: undefined, textColor: undefined,
@ -254,7 +254,7 @@ describe("parseStyle", () => {
text: "default", text: "default",
start: 17, start: 17,
end: 24 end: 24,
}]; }];
const actual = parseStyle(input); const actual = parseStyle(input);
@ -276,7 +276,7 @@ describe("parseStyle", () => {
text: "bold", text: "bold",
start: 0, start: 0,
end: 4 end: 4,
}, { }, {
bold: false, bold: false,
textColor: undefined, textColor: undefined,
@ -289,7 +289,7 @@ describe("parseStyle", () => {
text: " ", text: " ",
start: 4, start: 4,
end: 5 end: 5,
}, { }, {
bold: true, bold: true,
textColor: undefined, textColor: undefined,
@ -302,7 +302,7 @@ describe("parseStyle", () => {
text: "bold", text: "bold",
start: 5, start: 5,
end: 9 end: 9,
}]; }];
const actual = parseStyle(input); const actual = parseStyle(input);
@ -324,7 +324,7 @@ describe("parseStyle", () => {
text: "full", text: "full",
start: 0, start: 0,
end: 4 end: 4,
}, { }, {
bold: false, bold: false,
textColor: undefined, textColor: undefined,
@ -337,7 +337,7 @@ describe("parseStyle", () => {
text: "none", text: "none",
start: 4, start: 4,
end: 8 end: 8,
}]; }];
const actual = parseStyle(input); const actual = parseStyle(input);
@ -359,7 +359,7 @@ describe("parseStyle", () => {
text: "a", text: "a",
start: 0, start: 0,
end: 1 end: 1,
}]; }];
const actual = parseStyle(input); const actual = parseStyle(input);
@ -383,7 +383,7 @@ describe("parseStyle", () => {
text: rawString, text: rawString,
start: 0, start: 0,
end: rawString.length end: rawString.length,
}]; }];
const actual = parseStyle(input); const actual = parseStyle(input);

View file

@ -7,10 +7,10 @@ describe("parse Handlebars helper", () => {
it("should not introduce xss", () => { it("should not introduce xss", () => {
const testCases = [{ const testCases = [{
input: "<img onerror='location.href=\"//youtube.com\"'>", input: "<img onerror='location.href=\"//youtube.com\"'>",
expected: "&lt;img onerror&#x3D;&#x27;location.href&#x3D;&quot;//youtube.com&quot;&#x27;&gt;" expected: "&lt;img onerror&#x3D;&#x27;location.href&#x3D;&quot;//youtube.com&quot;&#x27;&gt;",
}, { }, {
input: "#&\">bug", input: "#&\">bug",
expected: "<span class=\"inline-channel\" role=\"button\" tabindex=\"0\" data-chan=\"#&amp;&quot;&gt;bug\">#&amp;&quot;&gt;bug</span>" expected: "<span class=\"inline-channel\" role=\"button\" tabindex=\"0\" data-chan=\"#&amp;&quot;&gt;bug\">#&amp;&quot;&gt;bug</span>",
}]; }];
const actual = testCases.map((testCase) => parse(testCase.input)); const actual = testCases.map((testCase) => parse(testCase.input));
@ -22,7 +22,7 @@ describe("parse Handlebars helper", () => {
it("should skip control codes", () => { it("should skip control codes", () => {
const testCases = [{ const testCases = [{
input: "text\x01with\x04control\x05codes", input: "text\x01with\x04control\x05codes",
expected: "textwithcontrolcodes" expected: "textwithcontrolcodes",
}]; }];
const actual = testCases.map((testCase) => parse(testCase.input)); const actual = testCases.map((testCase) => parse(testCase.input));
@ -37,13 +37,13 @@ describe("parse Handlebars helper", () => {
expected: expected:
"<a href=\"irc://freenode.net/thelounge\" target=\"_blank\" rel=\"noopener\">" + "<a href=\"irc://freenode.net/thelounge\" target=\"_blank\" rel=\"noopener\">" +
"irc://freenode.net/thelounge" + "irc://freenode.net/thelounge" +
"</a>" "</a>",
}, { }, {
input: "www.nooooooooooooooo.com", input: "www.nooooooooooooooo.com",
expected: expected:
"<a href=\"http://www.nooooooooooooooo.com\" target=\"_blank\" rel=\"noopener\">" + "<a href=\"http://www.nooooooooooooooo.com\" target=\"_blank\" rel=\"noopener\">" +
"www.nooooooooooooooo.com" + "www.nooooooooooooooo.com" +
"</a>" "</a>",
}, { }, {
input: "look at https://thelounge.github.io/ for more information", input: "look at https://thelounge.github.io/ for more information",
expected: expected:
@ -51,7 +51,7 @@ describe("parse Handlebars helper", () => {
"<a href=\"https://thelounge.github.io/\" target=\"_blank\" rel=\"noopener\">" + "<a href=\"https://thelounge.github.io/\" target=\"_blank\" rel=\"noopener\">" +
"https://thelounge.github.io/" + "https://thelounge.github.io/" +
"</a>" + "</a>" +
" for more information" " for more information",
}, { }, {
input: "use www.duckduckgo.com for privacy reasons", input: "use www.duckduckgo.com for privacy reasons",
expected: expected:
@ -59,13 +59,13 @@ describe("parse Handlebars helper", () => {
"<a href=\"http://www.duckduckgo.com\" target=\"_blank\" rel=\"noopener\">" + "<a href=\"http://www.duckduckgo.com\" target=\"_blank\" rel=\"noopener\">" +
"www.duckduckgo.com" + "www.duckduckgo.com" +
"</a>" + "</a>" +
" for privacy reasons" " for privacy reasons",
}, { }, {
input: "svn+ssh://example.org", input: "svn+ssh://example.org",
expected: expected:
"<a href=\"svn+ssh://example.org\" target=\"_blank\" rel=\"noopener\">" + "<a href=\"svn+ssh://example.org\" target=\"_blank\" rel=\"noopener\">" +
"svn+ssh://example.org" + "svn+ssh://example.org" +
"</a>" "</a>",
}]; }];
const actual = testCases.map((testCase) => parse(testCase.input)); const actual = testCases.map((testCase) => parse(testCase.input));
@ -96,7 +96,7 @@ describe("parse Handlebars helper", () => {
"<a href=\"https://theos.kyriasis.com/~kyrias/stats/archlinux.html\" target=\"_blank\" rel=\"noopener\">" + "<a href=\"https://theos.kyriasis.com/~kyrias/stats/archlinux.html\" target=\"_blank\" rel=\"noopener\">" +
"https://theos.kyriasis.com/~kyrias/stats/archlinux.html" + "https://theos.kyriasis.com/~kyrias/stats/archlinux.html" +
"</a>" + "</a>" +
"&gt;" "&gt;",
}, { }, {
input: "abc (www.example.com)", input: "abc (www.example.com)",
expected: expected:
@ -104,19 +104,19 @@ describe("parse Handlebars helper", () => {
"<a href=\"http://www.example.com\" target=\"_blank\" rel=\"noopener\">" + "<a href=\"http://www.example.com\" target=\"_blank\" rel=\"noopener\">" +
"www.example.com" + "www.example.com" +
"</a>" + "</a>" +
")" ")",
}, { }, {
input: "http://example.com/Test_(Page)", input: "http://example.com/Test_(Page)",
expected: expected:
"<a href=\"http://example.com/Test_(Page)\" target=\"_blank\" rel=\"noopener\">" + "<a href=\"http://example.com/Test_(Page)\" target=\"_blank\" rel=\"noopener\">" +
"http://example.com/Test_(Page)" + "http://example.com/Test_(Page)" +
"</a>" "</a>",
}, { }, {
input: "www.example.com/Test_(Page)", input: "www.example.com/Test_(Page)",
expected: expected:
"<a href=\"http://www.example.com/Test_(Page)\" target=\"_blank\" rel=\"noopener\">" + "<a href=\"http://www.example.com/Test_(Page)\" target=\"_blank\" rel=\"noopener\">" +
"www.example.com/Test_(Page)" + "www.example.com/Test_(Page)" +
"</a>" "</a>",
}]; }];
const actual = testCases.map((testCase) => parse(testCase.input)); const actual = testCases.map((testCase) => parse(testCase.input));
@ -128,10 +128,10 @@ describe("parse Handlebars helper", () => {
it("should not find urls", () => { it("should not find urls", () => {
const testCases = [{ const testCases = [{
input: "text www. text", input: "text www. text",
expected: "text www. text" expected: "text www. text",
}, { }, {
input: "http://.", input: "http://.",
expected: "http://." expected: "http://.",
}]; }];
const actual = testCases.map((testCase) => parse(testCase.input)); const actual = testCases.map((testCase) => parse(testCase.input));
@ -146,19 +146,19 @@ describe("parse Handlebars helper", () => {
expected: expected:
"<span class=\"inline-channel\" role=\"button\" tabindex=\"0\" data-chan=\"#a\">" + "<span class=\"inline-channel\" role=\"button\" tabindex=\"0\" data-chan=\"#a\">" +
"#a" + "#a" +
"</span>" "</span>",
}, { }, {
input: "#test", input: "#test",
expected: expected:
"<span class=\"inline-channel\" role=\"button\" tabindex=\"0\" data-chan=\"#test\">" + "<span class=\"inline-channel\" role=\"button\" tabindex=\"0\" data-chan=\"#test\">" +
"#test" + "#test" +
"</span>" "</span>",
}, { }, {
input: "#äöü", input: "#äöü",
expected: expected:
"<span class=\"inline-channel\" role=\"button\" tabindex=\"0\" data-chan=\"#äöü\">" + "<span class=\"inline-channel\" role=\"button\" tabindex=\"0\" data-chan=\"#äöü\">" +
"#äöü" + "#äöü" +
"</span>" "</span>",
}, { }, {
input: "inline #channel text", input: "inline #channel text",
expected: expected:
@ -166,20 +166,20 @@ describe("parse Handlebars helper", () => {
"<span class=\"inline-channel\" role=\"button\" tabindex=\"0\" data-chan=\"#channel\">" + "<span class=\"inline-channel\" role=\"button\" tabindex=\"0\" data-chan=\"#channel\">" +
"#channel" + "#channel" +
"</span>" + "</span>" +
" text" " text",
}, { }, {
input: "#1,000", input: "#1,000",
expected: expected:
"<span class=\"inline-channel\" role=\"button\" tabindex=\"0\" data-chan=\"#1,000\">" + "<span class=\"inline-channel\" role=\"button\" tabindex=\"0\" data-chan=\"#1,000\">" +
"#1,000" + "#1,000" +
"</span>" "</span>",
}, { }, {
input: "@#a", input: "@#a",
expected: expected:
"@" + "@" +
"<span class=\"inline-channel\" role=\"button\" tabindex=\"0\" data-chan=\"#a\">" + "<span class=\"inline-channel\" role=\"button\" tabindex=\"0\" data-chan=\"#a\">" +
"#a" + "#a" +
"</span>" "</span>",
}]; }];
const actual = testCases.map((testCase) => parse(testCase.input)); const actual = testCases.map((testCase) => parse(testCase.input));
@ -191,10 +191,10 @@ describe("parse Handlebars helper", () => {
it("should not find channels", () => { it("should not find channels", () => {
const testCases = [{ const testCases = [{
input: "hi#test", input: "hi#test",
expected: "hi#test" expected: "hi#test",
}, { }, {
input: "#", input: "#",
expected: "#" expected: "#",
}]; }];
const actual = testCases.map((testCase) => parse(testCase.input)); const actual = testCases.map((testCase) => parse(testCase.input));
@ -206,35 +206,35 @@ describe("parse Handlebars helper", () => {
it("should style like mirc", () => { it("should style like mirc", () => {
const testCases = [{ const testCases = [{
input: "\x02bold", input: "\x02bold",
expected: "<span class=\"irc-bold\">bold</span>" expected: "<span class=\"irc-bold\">bold</span>",
}, { }, {
input: "\x038yellowText", input: "\x038yellowText",
expected: "<span class=\"irc-fg8\">yellowText</span>" expected: "<span class=\"irc-fg8\">yellowText</span>",
}, { }, {
input: "\x030,0white,white", input: "\x030,0white,white",
expected: "<span class=\"irc-fg0 irc-bg0\">white,white</span>" expected: "<span class=\"irc-fg0 irc-bg0\">white,white</span>",
}, { }, {
input: "\x034,8yellowBGredText", input: "\x034,8yellowBGredText",
expected: "<span class=\"irc-fg4 irc-bg8\">yellowBGredText</span>" expected: "<span class=\"irc-fg4 irc-bg8\">yellowBGredText</span>",
}, { }, {
input: "\x1ditalic", input: "\x1ditalic",
expected: "<span class=\"irc-italic\">italic</span>" expected: "<span class=\"irc-italic\">italic</span>",
}, { }, {
input: "\x1funderline", input: "\x1funderline",
expected: "<span class=\"irc-underline\">underline</span>" expected: "<span class=\"irc-underline\">underline</span>",
}, { }, {
input: "\x02bold\x038yellow\x02nonBold\x03default", input: "\x02bold\x038yellow\x02nonBold\x03default",
expected: expected:
"<span class=\"irc-bold\">bold</span>" + "<span class=\"irc-bold\">bold</span>" +
"<span class=\"irc-bold irc-fg8\">yellow</span>" + "<span class=\"irc-bold irc-fg8\">yellow</span>" +
"<span class=\"irc-fg8\">nonBold</span>" + "<span class=\"irc-fg8\">nonBold</span>" +
"default" "default",
}, { }, {
input: "\x02bold\x02 \x02bold\x02", input: "\x02bold\x02 \x02bold\x02",
expected: expected:
"<span class=\"irc-bold\">bold</span>" + "<span class=\"irc-bold\">bold</span>" +
" " + " " +
"<span class=\"irc-bold\">bold</span>" "<span class=\"irc-bold\">bold</span>",
}]; }];
const actual = testCases.map((testCase) => parse(testCase.input)); const actual = testCases.map((testCase) => parse(testCase.input));
@ -253,14 +253,14 @@ describe("parse Handlebars helper", () => {
"<span class=\"irc-italic\">freenode.net</span>" + "<span class=\"irc-italic\">freenode.net</span>" +
"/" + "/" +
"<span class=\"irc-fg4 irc-bg8\">thelounge</span>" + "<span class=\"irc-fg4 irc-bg8\">thelounge</span>" +
"</a>" "</a>",
}, { }, {
input: "\x02#\x038,9thelounge", input: "\x02#\x038,9thelounge",
expected: expected:
"<span class=\"inline-channel\" role=\"button\" tabindex=\"0\" data-chan=\"#thelounge\">" + "<span class=\"inline-channel\" role=\"button\" tabindex=\"0\" data-chan=\"#thelounge\">" +
"<span class=\"irc-bold\">#</span>" + "<span class=\"irc-bold\">#</span>" +
"<span class=\"irc-bold irc-fg8 irc-bg9\">thelounge</span>" + "<span class=\"irc-bold irc-fg8 irc-bg9\">thelounge</span>" +
"</span>" "</span>",
}]; }];
const actual = testCases.map((testCase) => parse(testCase.input)); const actual = testCases.map((testCase) => parse(testCase.input));
@ -276,7 +276,7 @@ describe("parse Handlebars helper", () => {
"test " + "test " +
"<span class=\"inline-channel\" role=\"button\" tabindex=\"0\" data-chan=\"#&quot;testa\">" + "<span class=\"inline-channel\" role=\"button\" tabindex=\"0\" data-chan=\"#&quot;testa\">" +
"<span class=\"irc-fg12\">#&quot;testa</span>" + "<span class=\"irc-fg12\">#&quot;testa</span>" +
"</span>" "</span>",
}]; }];
const actual = testCases.map((testCase) => parse(testCase.input)); const actual = testCases.map((testCase) => parse(testCase.input));
@ -292,14 +292,14 @@ describe("parse Handlebars helper", () => {
"like.." + "like.." +
"<a href=\"http://example.com\" target=\"_blank\" rel=\"noopener\">" + "<a href=\"http://example.com\" target=\"_blank\" rel=\"noopener\">" +
"http://example.com" + "http://example.com" +
"</a>" "</a>",
}, { }, {
input: "like..HTTP://example.com", input: "like..HTTP://example.com",
expected: expected:
"like.." + "like.." +
"<a href=\"HTTP://example.com\" target=\"_blank\" rel=\"noopener\">" + "<a href=\"HTTP://example.com\" target=\"_blank\" rel=\"noopener\">" +
"HTTP://example.com" + "HTTP://example.com" +
"</a>" "</a>",
}]; }];
const actual = testCases.map((testCase) => parse(testCase.input)); const actual = testCases.map((testCase) => parse(testCase.input));
@ -315,7 +315,7 @@ describe("parse Handlebars helper", () => {
"" + "" +
"<a href=\"http://example.com/#hash\" target=\"_blank\" rel=\"noopener\">" + "<a href=\"http://example.com/#hash\" target=\"_blank\" rel=\"noopener\">" +
"http://example.com/#hash" + "http://example.com/#hash" +
"</a>" "</a>",
}]; }];
const actual = testCases.map((testCase) => parse(testCase.input)); const actual = testCases.map((testCase) => parse(testCase.input));

View file

@ -8,12 +8,12 @@ var ModeCommand = require("../../src/plugins/inputs/mode");
describe("Commands", function() { describe("Commands", function() {
describe("/mode", function() { describe("/mode", function() {
const channel = new Chan({ const channel = new Chan({
name: "#thelounge" name: "#thelounge",
}); });
const lobby = new Chan({ const lobby = new Chan({
name: "Network Lobby", name: "Network Lobby",
type: Chan.Type.LOBBY type: Chan.Type.LOBBY,
}); });
const testableNetwork = { const testableNetwork = {
@ -22,8 +22,8 @@ describe("Commands", function() {
irc: { irc: {
raw: function() { raw: function() {
testableNetwork.lastCommand = Array.prototype.join.call(arguments, " "); testableNetwork.lastCommand = Array.prototype.join.call(arguments, " ");
} },
} },
}; };
it("should not mess with the given target", function() { it("should not mess with the given target", function() {

View file

@ -12,10 +12,10 @@ describe("Chan", function() {
messages: [ messages: [
new Msg(), new Msg(),
new Msg({ new Msg({
text: "Message to be found" text: "Message to be found",
}), }),
new Msg() new Msg(),
] ],
}); });
it("should find a message in the list of messages", function() { it("should find a message in the list of messages", function() {
@ -36,10 +36,10 @@ describe("Chan", function() {
{symbol: "&", mode: "a"}, {symbol: "&", mode: "a"},
{symbol: "@", mode: "o"}, {symbol: "@", mode: "o"},
{symbol: "%", mode: "h"}, {symbol: "%", mode: "h"},
{symbol: "+", mode: "v"} {symbol: "+", mode: "v"},
] ],
} },
} },
}; };
var prefixLookup = {}; var prefixLookup = {};
@ -58,12 +58,12 @@ describe("Chan", function() {
it("should sort a simple user list", function() { it("should sort a simple user list", function() {
var chan = new Chan({users: [ var chan = new Chan({users: [
"JocelynD", "YaManicKill", "astorije", "xPaw", "Max-P" "JocelynD", "YaManicKill", "astorije", "xPaw", "Max-P",
].map(makeUser)}); ].map(makeUser)});
chan.sortUsers(network); chan.sortUsers(network);
expect(getUserNames(chan)).to.deep.equal([ expect(getUserNames(chan)).to.deep.equal([
"astorije", "JocelynD", "Max-P", "xPaw", "YaManicKill" "astorije", "JocelynD", "Max-P", "xPaw", "YaManicKill",
]); ]);
}); });
@ -78,7 +78,7 @@ describe("Chan", function() {
chan.sortUsers(network); chan.sortUsers(network);
expect(getUserNames(chan)).to.deep.equal([ expect(getUserNames(chan)).to.deep.equal([
"xPaw", "JocelynD", "Max-P", "astorije", "YaManicKill" "xPaw", "JocelynD", "Max-P", "astorije", "YaManicKill",
]); ]);
}); });
@ -107,13 +107,13 @@ describe("Chan", function() {
it("should parse special characters successfully", function() { it("should parse special characters successfully", function() {
var chan = new Chan({users: [ var chan = new Chan({users: [
"[foo", "]foo", "(foo)", "{foo}", "<foo>", "_foo", "@foo", "^foo", "[foo", "]foo", "(foo)", "{foo}", "<foo>", "_foo", "@foo", "^foo",
"&foo", "!foo", "+foo", "Foo" "&foo", "!foo", "+foo", "Foo",
].map(makeUser)}); ].map(makeUser)});
chan.sortUsers(network); chan.sortUsers(network);
expect(getUserNames(chan)).to.deep.equal([ expect(getUserNames(chan)).to.deep.equal([
"!foo", "&foo", "(foo)", "+foo", "<foo>", "@foo", "[foo", "]foo", "!foo", "&foo", "(foo)", "+foo", "<foo>", "@foo", "[foo", "]foo",
"^foo", "_foo", "Foo", "{foo}" "^foo", "_foo", "Foo", "{foo}",
]); ]);
}); });
}); });

View file

@ -21,7 +21,7 @@ describe("Msg", function() {
thumb: "", thumb: "",
type: "link", type: "link",
shown: true, shown: true,
}] }],
}); });
it("should find a preview given an existing link", function() { it("should find a preview given an existing link", function() {

View file

@ -19,7 +19,7 @@ describe("Network", function() {
new Chan({name: "&secure", key: "bar"}), new Chan({name: "&secure", key: "bar"}),
new Chan({name: "Channel List", type: Chan.Type.SPECIAL}), new Chan({name: "Channel List", type: Chan.Type.SPECIAL}),
new Chan({name: "PrivateChat", type: Chan.Type.QUERY}), new Chan({name: "PrivateChat", type: Chan.Type.QUERY}),
] ],
}); });
network.setNick("chillin`"); network.setNick("chillin`");
@ -41,7 +41,7 @@ describe("Network", function() {
{name: "&foobar", key: ""}, {name: "&foobar", key: ""},
{name: "#secret", key: "foo"}, {name: "#secret", key: "foo"},
{name: "&secure", key: "bar"}, {name: "&secure", key: "bar"},
] ],
}); });
}); });
@ -52,7 +52,7 @@ describe("Network", function() {
new Chan({name: "AAAA!", type: Chan.Type.QUERY}), new Chan({name: "AAAA!", type: Chan.Type.QUERY}),
new Chan({name: "#thelounge"}), new Chan({name: "#thelounge"}),
new Chan({name: "&foobar"}), new Chan({name: "&foobar"}),
] ],
}); });
network.channels.push(new Chan({name: "#swag"})); network.channels.push(new Chan({name: "#swag"}));
@ -65,24 +65,24 @@ describe("Network", function() {
name: "#506-bug-fix", name: "#506-bug-fix",
messages: [ messages: [
new Msg({ new Msg({
text: "message in constructor" text: "message in constructor",
}) }),
] ],
}); });
var network = new Network({ var network = new Network({
name: "networkName", name: "networkName",
channels: [ channels: [
chan chan,
] ],
}); });
chan.messages.push(new Msg({ chan.messages.push(new Msg({
text: "message in original instance" text: "message in original instance",
})); }));
network.channels[1].messages.push(new Msg({ network.channels[1].messages.push(new Msg({
text: "message after network creation" text: "message after network creation",
})); }));
expect(network.channels[1].messages).to.have.lengthOf(3); expect(network.channels[1].messages).to.have.lengthOf(3);

View file

@ -63,8 +63,8 @@ function startLdapServer(callback) {
cn: ["john doe"], cn: ["john doe"],
sn: ["johnny"], sn: ["johnny"],
uid: ["johndoe"], uid: ["johndoe"],
memberof: [baseDN] memberof: [baseDN],
} },
}; };
if (req.filter.matches(obj.attributes)) { if (req.filter.matches(obj.attributes)) {

View file

@ -29,7 +29,7 @@ describe("Link plugin", function() {
it("should be able to fetch basic information about URLs", function(done) { it("should be able to fetch basic information about URLs", function(done) {
const url = "http://localhost:9002/basic"; const url = "http://localhost:9002/basic";
const message = this.irc.createMessage({ const message = this.irc.createMessage({
text: url text: url,
}); });
link(this.irc, this.network.channels[0], message); link(this.irc, this.network.channels[0], message);
@ -60,7 +60,7 @@ describe("Link plugin", function() {
it("should prefer og:title over title", function(done) { it("should prefer og:title over title", function(done) {
const message = this.irc.createMessage({ const message = this.irc.createMessage({
text: "http://localhost:9002/basic-og" text: "http://localhost:9002/basic-og",
}); });
link(this.irc, this.network.channels[0], message); link(this.irc, this.network.channels[0], message);
@ -77,7 +77,7 @@ describe("Link plugin", function() {
it("should prefer og:description over description", function(done) { it("should prefer og:description over description", function(done) {
const message = this.irc.createMessage({ const message = this.irc.createMessage({
text: "http://localhost:9002/description-og" text: "http://localhost:9002/description-og",
}); });
link(this.irc, this.network.channels[0], message); link(this.irc, this.network.channels[0], message);
@ -94,7 +94,7 @@ describe("Link plugin", function() {
it("should find og:image with full url", function(done) { it("should find og:image with full url", function(done) {
const message = this.irc.createMessage({ const message = this.irc.createMessage({
text: "http://localhost:9002/thumb" text: "http://localhost:9002/thumb",
}); });
link(this.irc, this.network.channels[0], message); link(this.irc, this.network.channels[0], message);
@ -112,7 +112,7 @@ describe("Link plugin", function() {
it("should find image_src", function(done) { it("should find image_src", function(done) {
const message = this.irc.createMessage({ const message = this.irc.createMessage({
text: "http://localhost:9002/thumb-image-src" text: "http://localhost:9002/thumb-image-src",
}); });
link(this.irc, this.network.channels[0], message); link(this.irc, this.network.channels[0], message);
@ -129,7 +129,7 @@ describe("Link plugin", function() {
it("should correctly resolve relative protocol", function(done) { it("should correctly resolve relative protocol", function(done) {
const message = this.irc.createMessage({ const message = this.irc.createMessage({
text: "http://localhost:9002/thumb-image-src" text: "http://localhost:9002/thumb-image-src",
}); });
link(this.irc, this.network.channels[0], message); link(this.irc, this.network.channels[0], message);
@ -146,7 +146,7 @@ describe("Link plugin", function() {
it("should resolve url correctly for relative url", function(done) { it("should resolve url correctly for relative url", function(done) {
const message = this.irc.createMessage({ const message = this.irc.createMessage({
text: "http://localhost:9002/relative-thumb" text: "http://localhost:9002/relative-thumb",
}); });
link(this.irc, this.network.channels[0], message); link(this.irc, this.network.channels[0], message);
@ -165,7 +165,7 @@ describe("Link plugin", function() {
it("should send untitled page if there is a thumbnail", function(done) { it("should send untitled page if there is a thumbnail", function(done) {
const message = this.irc.createMessage({ const message = this.irc.createMessage({
text: "http://localhost:9002/thumb-no-title" text: "http://localhost:9002/thumb-no-title",
}); });
link(this.irc, this.network.channels[0], message); link(this.irc, this.network.channels[0], message);
@ -184,7 +184,7 @@ describe("Link plugin", function() {
it("should not send thumbnail if image is 404", function(done) { it("should not send thumbnail if image is 404", function(done) {
const message = this.irc.createMessage({ const message = this.irc.createMessage({
text: "http://localhost:9002/thumb-404" text: "http://localhost:9002/thumb-404",
}); });
link(this.irc, this.network.channels[0], message); link(this.irc, this.network.channels[0], message);
@ -203,7 +203,7 @@ describe("Link plugin", function() {
it("should send image preview", function(done) { it("should send image preview", function(done) {
const message = this.irc.createMessage({ const message = this.irc.createMessage({
text: "http://localhost:9002/real-test-image.png" text: "http://localhost:9002/real-test-image.png",
}); });
link(this.irc, this.network.channels[0], message); link(this.irc, this.network.channels[0], message);
@ -218,7 +218,7 @@ describe("Link plugin", function() {
it("should load multiple URLs found in messages", function(done) { it("should load multiple URLs found in messages", function(done) {
const message = this.irc.createMessage({ const message = this.irc.createMessage({
text: "http://localhost:9002/one http://localhost:9002/two" text: "http://localhost:9002/one http://localhost:9002/two",
}); });
link(this.irc, this.network.channels[0], message); link(this.irc, this.network.channels[0], message);

View file

@ -34,7 +34,7 @@ describe("Image storage", function() {
it("should store the thumbnail", function(done) { it("should store the thumbnail", function(done) {
const message = this.irc.createMessage({ const message = this.irc.createMessage({
text: "http://localhost:9003/thumb" text: "http://localhost:9003/thumb",
}); });
link(this.irc, this.network.channels[0], message); link(this.irc, this.network.channels[0], message);
@ -53,7 +53,7 @@ describe("Image storage", function() {
it("should store the image", function(done) { it("should store the image", function(done) {
const message = this.irc.createMessage({ const message = this.irc.createMessage({
text: "http://localhost:9003/real-test-image.png" text: "http://localhost:9003/real-test-image.png",
}); });
link(this.irc, this.network.channels[0], message); link(this.irc, this.network.channels[0], message);

View file

@ -56,8 +56,8 @@ describe("Server", () => {
reconnection: false, reconnection: false,
timeout: 1000, timeout: 1000,
transports: [ transports: [
"websocket" "websocket",
] ],
}); });
// Server emits events faster than the test can bind them // Server emits events faster than the test can bind them

View file

@ -7,37 +7,37 @@ describe("Clean IRC messages", function() {
it("should remove all formatting", function() { it("should remove all formatting", function() {
const testCases = [{ const testCases = [{
input: "\x0303", input: "\x0303",
expected: "" expected: "",
}, { }, {
input: "\x02bold", input: "\x02bold",
expected: "bold" expected: "bold",
}, { }, {
input: "\x038yellowText", input: "\x038yellowText",
expected: "yellowText" expected: "yellowText",
}, { }, {
input: "\x030,0white,white", input: "\x030,0white,white",
expected: "white,white" expected: "white,white",
}, { }, {
input: "\x034,8yellowBGredText", input: "\x034,8yellowBGredText",
expected: "yellowBGredText" expected: "yellowBGredText",
}, { }, {
input: "\x1ditalic", input: "\x1ditalic",
expected: "italic" expected: "italic",
}, { }, {
input: "\x1funderline", input: "\x1funderline",
expected: "underline" expected: "underline",
}, { }, {
input: "\x02bold\x038yellow\x02nonBold\x03default", input: "\x02bold\x038yellow\x02nonBold\x03default",
expected: "boldyellownonBolddefault" expected: "boldyellownonBolddefault",
}, { }, {
input: "\x02bold\x02 \x02bold\x02", input: "\x02bold\x02 \x02bold\x02",
expected: "bold bold" expected: "bold bold",
}, { }, {
input: "\x02irc\x0f://\x1dfreenode.net\x0f/\x034,8thelounge", input: "\x02irc\x0f://\x1dfreenode.net\x0f/\x034,8thelounge",
expected: "irc://freenode.net/thelounge" expected: "irc://freenode.net/thelounge",
}, { }, {
input: "\x02#\x038,9thelounge", input: "\x02#\x038,9thelounge",
expected: "#thelounge" expected: "#thelounge",
}]; }];
const actual = testCases.map((testCase) => Helper.cleanIrcMessage(testCase.input)); const actual = testCases.map((testCase) => Helper.cleanIrcMessage(testCase.input));

View file

@ -35,11 +35,11 @@ module.exports = {
return new Network({ return new Network({
host: "example.com", host: "example.com",
channels: [new Chan({ channels: [new Chan({
name: "#test-channel" name: "#test-channel",
})] })],
}); });
}, },
createWebserver: function() { createWebserver: function() {
return express(); return express();
} },
}; };

View file

@ -16,7 +16,7 @@ const config = {
output: { output: {
path: path.resolve(__dirname, "public"), path: path.resolve(__dirname, "public"),
filename: "[name]", filename: "[name]",
publicPath: "/" publicPath: "/",
}, },
module: { module: {
rules: [ rules: [
@ -31,12 +31,12 @@ const config = {
presets: [ presets: [
["env", { ["env", {
targets: { targets: {
browsers: "last 2 versions" browsers: "last 2 versions",
} },
}] }],
] ],
} },
} },
}, },
{ {
test: /\.tpl$/, test: /\.tpl$/,
@ -47,15 +47,15 @@ const config = {
loader: "handlebars-loader", loader: "handlebars-loader",
options: { options: {
helperDirs: [ helperDirs: [
path.resolve(__dirname, "client/js/libs/handlebars") path.resolve(__dirname, "client/js/libs/handlebars"),
], ],
extensions: [ extensions: [
".tpl" ".tpl",
], ],
} },
} },
}, },
] ],
}, },
externals: { externals: {
json3: "JSON", // socket.io uses json3.js, but we do not target any browsers that need it json3: "JSON", // socket.io uses json3.js, but we do not target any browsers that need it
@ -64,31 +64,31 @@ const config = {
new CopyPlugin([ new CopyPlugin([
{ {
from: "./node_modules/font-awesome/fonts/fontawesome-webfont.woff*", from: "./node_modules/font-awesome/fonts/fontawesome-webfont.woff*",
to: "fonts/[name].[ext]" to: "fonts/[name].[ext]",
}, },
{ {
from: "./client/js/loading-slow-alert.js", from: "./client/js/loading-slow-alert.js",
to: "js/[name].[ext]" to: "js/[name].[ext]",
}, },
{ // TODO: Build index.html with handlebars { // TODO: Build index.html with handlebars
from: "./client/*", from: "./client/*",
to: "[name].[ext]" to: "[name].[ext]",
}, },
{ {
from: "./client/audio/*", from: "./client/audio/*",
to: "audio/[name].[ext]" to: "audio/[name].[ext]",
}, },
{ {
from: "./client/img/*", from: "./client/img/*",
to: "img/[name].[ext]" to: "img/[name].[ext]",
}, },
{ {
from: "./client/themes/*", from: "./client/themes/*",
to: "themes/[name].[ext]" to: "themes/[name].[ext]",
}, },
{ // TODO: Build css with postcss { // TODO: Build css with postcss
from: "./client/css/*", from: "./client/css/*",
to: "css/[name].[ext]" to: "css/[name].[ext]",
}, },
]), ]),
// socket.io uses debug, we don't need it // socket.io uses debug, we don't need it
@ -96,9 +96,9 @@ const config = {
// automatically split all vendor dependencies into a separate bundle // automatically split all vendor dependencies into a separate bundle
new webpack.optimize.CommonsChunkPlugin({ new webpack.optimize.CommonsChunkPlugin({
name: "js/bundle.vendor.js", name: "js/bundle.vendor.js",
minChunks: (module) => module.context && module.context.indexOf("node_modules") !== -1 minChunks: (module) => module.context && module.context.indexOf("node_modules") !== -1,
}) }),
] ],
}; };
// ********************************* // *********************************
@ -108,7 +108,7 @@ const config = {
if (process.env.NODE_ENV === "production") { if (process.env.NODE_ENV === "production") {
config.plugins.push(new webpack.optimize.UglifyJsPlugin({ config.plugins.push(new webpack.optimize.UglifyJsPlugin({
sourceMap: true, sourceMap: true,
comments: false comments: false,
})); }));
} }