Add typeof check for body

pull/28788/head^2
Florian Duros 2022-10-26 19:19:32 +02:00
parent 39f1dc224c
commit 0a7f44b226
No known key found for this signature in database
GPG Key ID: 9700AA5870258A0B
2 changed files with 3 additions and 3 deletions

View File

@ -60,9 +60,6 @@ function getHtmlReplyFallback(mxEvent: MatrixEvent): string {
function getTextReplyFallback(mxEvent: MatrixEvent): string {
const body = mxEvent.getContent().body;
if (!body || typeof body !== 'string') {
return "";
}
const lines = body.split("\n").map(l => l.trim());
if (lines.length > 2 && lines[0].startsWith("> ") && lines[1].length === 0) {
return `${lines[0]}\n\n`;

View File

@ -44,6 +44,9 @@ function getHtmlReplyFallback(mxEvent: MatrixEvent): string {
function getTextReplyFallback(mxEvent: MatrixEvent): string {
const body = mxEvent.getContent().body;
if (!body || typeof body !== 'string') {
return "";
}
const lines = body.split("\n").map(l => l.trim());
if (lines.length > 2 && lines[0].startsWith("> ") && lines[1].length === 0) {
return `${lines[0]}\n\n`;