Add typeof check for body
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…
Reference in New Issue