Fix #1413 - Handle hex colours when cleaning string

This commit is contained in:
Pavel Djundik 2017-11-22 16:03:59 +02:00
parent ca389c914f
commit 28b084af69
2 changed files with 10 additions and 2 deletions

View File

@ -1,4 +1,3 @@
"use strict"; "use strict";
// TODO: This does not strip hex based colours - issue #1413 module.exports = (message) => message.replace(/\x02|\x1D|\x1F|\x16|\x0F|\x03(?:[0-9]{1,2}(?:,[0-9]{1,2})?)?|\x04(?:[0-9a-f]{6}(?:,[0-9a-f]{6})?)?/gi, "").trim();
module.exports = (message) => message.replace(/\x02|\x1D|\x1F|\x16|\x0F|\x03(?:[0-9]{1,2}(?:,[0-9]{1,2})?)?/g, "").trim();

View File

@ -38,6 +38,15 @@ describe("cleanIrcMessage", function() {
}, { }, {
input: "\x02#\x038,9thelounge", input: "\x02#\x038,9thelounge",
expected: "#thelounge", expected: "#thelounge",
}, {
input: "\x04DDEEAA,BBEEFF#\x038,9thelou\x04FFAACC\x0311\x04nge",
expected: "#thelounge",
}, {
input: "\x04ddEEffhex\x04 color\x04EEffCC,AAaaCC clean",
expected: "hex color clean",
}, {
input: "\x04 AAaaAA\x03 11 \x04Invalid,Hex ",
expected: "AAaaAA 11 Invalid,Hex",
}]; }];
const actual = testCases.map((testCase) => cleanIrcMessage(testCase.input)); const actual = testCases.map((testCase) => cleanIrcMessage(testCase.input));