diff --git a/src/mfm/html.ts b/src/mfm/html.ts index 64208af88..71b473947 100644 --- a/src/mfm/html.ts +++ b/src/mfm/html.ts @@ -92,6 +92,10 @@ const handlers: { [key: string]: (window: any, token: any, mentionedRemoteUsers: }; export default (tokens: TextElement[], mentionedRemoteUsers: INote['mentionedRemoteUsers'] = []) => { + if (tokens == null) { + return null; + } + const { window } = new JSDOM(''); for (const token of tokens) { diff --git a/src/mfm/parse/index.ts b/src/mfm/parse/index.ts index 2b6a459b1..8d71409e5 100644 --- a/src/mfm/parse/index.ts +++ b/src/mfm/parse/index.ts @@ -43,8 +43,7 @@ export type TextElement = { type: 'text', content: string } export type TextElementProcessor = (text: string, i: number) => TextElement | TextElement[]; export default (source: string): TextElement[] => { - - if (source == '') { + if (source == null || source == '') { return null; }