mirror of
https://github.com/vector-im/element-web.git
synced 2025-08-21 06:21:03 +02:00
Add typeof check for body
This commit is contained in:
parent
39f1dc224c
commit
0a7f44b226
@ -60,9 +60,6 @@ function getHtmlReplyFallback(mxEvent: MatrixEvent): string {
|
|||||||
|
|
||||||
function getTextReplyFallback(mxEvent: MatrixEvent): string {
|
function getTextReplyFallback(mxEvent: MatrixEvent): string {
|
||||||
const body = mxEvent.getContent().body;
|
const body = mxEvent.getContent().body;
|
||||||
if (!body || typeof body !== 'string') {
|
|
||||||
return "";
|
|
||||||
}
|
|
||||||
const lines = body.split("\n").map(l => l.trim());
|
const lines = body.split("\n").map(l => l.trim());
|
||||||
if (lines.length > 2 && lines[0].startsWith("> ") && lines[1].length === 0) {
|
if (lines.length > 2 && lines[0].startsWith("> ") && lines[1].length === 0) {
|
||||||
return `${lines[0]}\n\n`;
|
return `${lines[0]}\n\n`;
|
||||||
|
@ -44,6 +44,9 @@ function getHtmlReplyFallback(mxEvent: MatrixEvent): string {
|
|||||||
|
|
||||||
function getTextReplyFallback(mxEvent: MatrixEvent): string {
|
function getTextReplyFallback(mxEvent: MatrixEvent): string {
|
||||||
const body = mxEvent.getContent().body;
|
const body = mxEvent.getContent().body;
|
||||||
|
if (!body || typeof body !== 'string') {
|
||||||
|
return "";
|
||||||
|
}
|
||||||
const lines = body.split("\n").map(l => l.trim());
|
const lines = body.split("\n").map(l => l.trim());
|
||||||
if (lines.length > 2 && lines[0].startsWith("> ") && lines[1].length === 0) {
|
if (lines.length > 2 && lines[0].startsWith("> ") && lines[1].length === 0) {
|
||||||
return `${lines[0]}\n\n`;
|
return `${lines[0]}\n\n`;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user