You've already forked matrix-react-sdk
mirror of
https://github.com/matrix-org/matrix-react-sdk.git
synced 2025-07-30 02:21:17 +03:00
fix bug detected by tests
This commit is contained in:
@ -223,14 +223,14 @@ function parseHtmlMessage(html, partCreator, isQuotedMessage) {
|
|||||||
function parsePlainTextMessage(body, partCreator, isQuotedMessage) {
|
function parsePlainTextMessage(body, partCreator, isQuotedMessage) {
|
||||||
const lines = body.split("\n");
|
const lines = body.split("\n");
|
||||||
const parts = lines.reduce((parts, line, i) => {
|
const parts = lines.reduce((parts, line, i) => {
|
||||||
const isLast = i === lines.length - 1;
|
|
||||||
if (!isLast) {
|
|
||||||
parts.push(partCreator.newline());
|
|
||||||
}
|
|
||||||
if (isQuotedMessage) {
|
if (isQuotedMessage) {
|
||||||
parts.push(partCreator.plain(QUOTE_LINE_PREFIX));
|
parts.push(partCreator.plain(QUOTE_LINE_PREFIX));
|
||||||
}
|
}
|
||||||
parts.push(...parseAtRoomMentions(line, partCreator));
|
parts.push(...parseAtRoomMentions(line, partCreator));
|
||||||
|
const isLast = i === lines.length - 1;
|
||||||
|
if (!isLast) {
|
||||||
|
parts.push(partCreator.newline());
|
||||||
|
}
|
||||||
return parts;
|
return parts;
|
||||||
}, []);
|
}, []);
|
||||||
return parts;
|
return parts;
|
||||||
|
@ -71,10 +71,10 @@ describe('editor/deserialize', function() {
|
|||||||
describe('text messages', function() {
|
describe('text messages', function() {
|
||||||
it('test with newlines', function() {
|
it('test with newlines', function() {
|
||||||
const parts = normalize(parseEvent(textMessage("hello\nworld"), createPartCreator()));
|
const parts = normalize(parseEvent(textMessage("hello\nworld"), createPartCreator()));
|
||||||
expect(parts.length).toBe(3);
|
|
||||||
expect(parts[0]).toStrictEqual({type: "plain", text: "hello"});
|
expect(parts[0]).toStrictEqual({type: "plain", text: "hello"});
|
||||||
expect(parts[1]).toStrictEqual({type: "newline", text: "\n"});
|
expect(parts[1]).toStrictEqual({type: "newline", text: "\n"});
|
||||||
expect(parts[2]).toStrictEqual({type: "plain", text: "world"});
|
expect(parts[2]).toStrictEqual({type: "plain", text: "world"});
|
||||||
|
expect(parts.length).toBe(3);
|
||||||
});
|
});
|
||||||
it('@room pill', function() {
|
it('@room pill', function() {
|
||||||
const parts = normalize(parseEvent(textMessage("text message for @room"), createPartCreator()));
|
const parts = normalize(parseEvent(textMessage("text message for @room"), createPartCreator()));
|
||||||
|
Reference in New Issue
Block a user