From 64c0f623394fbbad7c348e3a279ddfc2f736d6f6 Mon Sep 17 00:00:00 2001 From: riku6460 <17585784+riku6460@users.noreply.github.com> Date: Fri, 14 Jun 2024 06:36:37 +0900 Subject: [PATCH] =?UTF-8?q?MfmService.toHtml=20=E3=82=92=20JSDOM=20?= =?UTF-8?q?=E3=81=AB=E6=88=BB=E3=81=99=20(MisskeyIO#647)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/backend/src/core/MfmService.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/packages/backend/src/core/MfmService.ts b/packages/backend/src/core/MfmService.ts index 9786f8b8b..4e1e8d902 100644 --- a/packages/backend/src/core/MfmService.ts +++ b/packages/backend/src/core/MfmService.ts @@ -6,7 +6,7 @@ import { URL } from 'node:url'; import { Inject, Injectable } from '@nestjs/common'; import * as parse5 from 'parse5'; -import { Window, XMLSerializer } from 'happy-dom'; +import { JSDOM } from 'jsdom'; import { DI } from '@/di-symbols.js'; import type { Config } from '@/config.js'; import { intersperse } from '@/misc/prelude/array.js'; @@ -243,9 +243,9 @@ export class MfmService { return null; } - const { window } = new Window(); + const fragment = JSDOM.fragment(''); - const doc = window.document; + const doc = fragment.ownerDocument; const body = doc.createElement('p'); @@ -461,6 +461,6 @@ export class MfmService { appendChildren(nodes, body); - return new XMLSerializer().serializeToString(body); + return body.outerHTML; } }