Merge pull request #3638 from thelounge/xpaw/control-space
Replace control codes with a space
This commit is contained in:
commit
280018e052
@ -4,7 +4,7 @@ const expect = require("chai").expect;
|
|||||||
const parseStyle = require("../../../../../client/js/helpers/ircmessageparser/parseStyle").default;
|
const parseStyle = require("../../../../../client/js/helpers/ircmessageparser/parseStyle").default;
|
||||||
|
|
||||||
describe("parseStyle", () => {
|
describe("parseStyle", () => {
|
||||||
it("should skip control codes", () => {
|
it("should replace control codes", () => {
|
||||||
const input = "text\x01with\x04control\x05codes";
|
const input = "text\x01with\x04control\x05codes";
|
||||||
const expected = [
|
const expected = [
|
||||||
{
|
{
|
||||||
@ -20,7 +20,7 @@ describe("parseStyle", () => {
|
|||||||
text: "text withcontrol codes",
|
text: "text withcontrol codes",
|
||||||
|
|
||||||
start: 0,
|
start: 0,
|
||||||
end: 20,
|
end: 22,
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
|
@ -48,7 +48,7 @@ describe("IRC formatted message parser", () => {
|
|||||||
input:
|
input:
|
||||||
"\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0B\x0C\x0D\x0E\x0F\x10\x11\x12\x13\x14\x15\x16\x17\x18\x19\x1A\x1B\x1C\x1B\x1D\x1D\x1E\x1Ftext\x0Awithcontrolcodestest",
|
"\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0B\x0C\x0D\x0E\x0F\x10\x11\x12\x13\x14\x15\x16\x17\x18\x19\x1A\x1B\x1C\x1B\x1D\x1D\x1E\x1Ftext\x0Awithcontrolcodestest",
|
||||||
expected:
|
expected:
|
||||||
'<span class="irc-underline irc-strikethrough irc-monospace">text\nwithcontrolcodestest</span>',
|
' <span class="irc-bold"> </span> <span class="irc-monospace"> </span><span class="irc-underline irc-strikethrough irc-monospace">text\nwithcontrolcodestest</span>',
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
@ -606,4 +606,14 @@ describe("IRC formatted message parser", () => {
|
|||||||
"</span>"
|
"</span>"
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it("should find links separated by tab character", async () => {
|
||||||
|
const input = "example.com\texample.org";
|
||||||
|
const actual = await getParsedMessageContents(input);
|
||||||
|
|
||||||
|
expect(actual).to.equal(
|
||||||
|
'<a href="http://example.com" dir="auto" target="_blank" rel="noopener">example.com</a>' +
|
||||||
|
' <a href="http://example.org" dir="auto" target="_blank" rel="noopener">example.org</a>'
|
||||||
|
);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
Loading…
Reference in New Issue
Block a user