mirror of
https://github.com/thelounge/thelounge
synced 2024-11-27 06:20:26 +00:00
Merge pull request #1731 from thelounge/xpaw/fix-1413
Handle hex colours when cleaning string
This commit is contained in:
commit
643a8222a6
2 changed files with 12 additions and 2 deletions
|
@ -1,4 +1,5 @@
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
// TODO: This does not strip hex based colours - issue #1413
|
const matchFormatting = /\x02|\x1D|\x1F|\x16|\x0F|\x03(?:[0-9]{1,2}(?:,[0-9]{1,2})?)?|\x04(?:[0-9a-f]{6}(?:,[0-9a-f]{6})?)?/gi;
|
||||||
module.exports = (message) => message.replace(/\x02|\x1D|\x1F|\x16|\x0F|\x03(?:[0-9]{1,2}(?:,[0-9]{1,2})?)?/g, "").trim();
|
|
||||||
|
module.exports = (message) => message.replace(matchFormatting, "").trim();
|
||||||
|
|
|
@ -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));
|
||||||
|
|
Loading…
Reference in a new issue