summaryrefslogtreecommitdiff
path: root/packages/backend/src
diff options
context:
space:
mode:
authorpotpro <pptppctt@gmail.com>2023-02-22 17:32:45 +0900
committerGitHub <noreply@github.com>2023-02-22 17:32:45 +0900
commitbd13ea3d2cfc3a56a602c2a2c13c72ab6c0f8426 (patch)
tree33699c0b54cb69ffd8f79f44307a78bd2f83277d /packages/backend/src
parentfix(client): ユーザーのハッシュタグ検索が機能していない... (diff)
downloadsharkey-bd13ea3d2cfc3a56a602c2a2c13c72ab6c0f8426.tar.gz
sharkey-bd13ea3d2cfc3a56a602c2a2c13c72ab6c0f8426.tar.bz2
sharkey-bd13ea3d2cfc3a56a602c2a2c13c72ab6c0f8426.zip
MFMのDOM ParserをJSDOMからhappy-domに変更する (#10016)
Co-authored-by: syuilo <Syuilotan@yahoo.co.jp>
Diffstat (limited to 'packages/backend/src')
-rw-r--r--packages/backend/src/core/MfmService.ts14
1 files changed, 7 insertions, 7 deletions
diff --git a/packages/backend/src/core/MfmService.ts b/packages/backend/src/core/MfmService.ts
index 8d961452c7..9b2d5dc0ff 100644
--- a/packages/backend/src/core/MfmService.ts
+++ b/packages/backend/src/core/MfmService.ts
@@ -1,7 +1,7 @@
import { URL } from 'node:url';
import { Inject, Injectable } from '@nestjs/common';
import * as parse5 from 'parse5';
-import { JSDOM } from 'jsdom';
+import { Window } from 'happy-dom';
import { DI } from '@/di-symbols.js';
import type { Config } from '@/config.js';
import { intersperse } from '@/misc/prelude/array.js';
@@ -235,7 +235,7 @@ export class MfmService {
return null;
}
- const { window } = new JSDOM('');
+ const { window } = new Window();
const doc = window.document;
@@ -300,7 +300,7 @@ export class MfmService {
hashtag: (node) => {
const a = doc.createElement('a');
- a.href = `${this.config.url}/tags/${node.props.hashtag}`;
+ a.setAttribute('href', `${this.config.url}/tags/${node.props.hashtag}`);
a.textContent = `#${node.props.hashtag}`;
a.setAttribute('rel', 'tag');
return a;
@@ -326,7 +326,7 @@ export class MfmService {
link: (node) => {
const a = doc.createElement('a');
- a.href = node.props.url;
+ a.setAttribute('href', node.props.url);
appendChildren(node.children, a);
return a;
},
@@ -335,7 +335,7 @@ export class MfmService {
const a = doc.createElement('a');
const { username, host, acct } = node.props;
const remoteUserInfo = mentionedRemoteUsers.find(remoteUser => remoteUser.username === username && remoteUser.host === host);
- a.href = remoteUserInfo ? (remoteUserInfo.url ? remoteUserInfo.url : remoteUserInfo.uri) : `${this.config.url}/${acct}`;
+ a.setAttribute('href', remoteUserInfo ? (remoteUserInfo.url ? remoteUserInfo.url : remoteUserInfo.uri) : `${this.config.url}/${acct}`);
a.className = 'u-url mention';
a.textContent = acct;
return a;
@@ -360,14 +360,14 @@ export class MfmService {
url: (node) => {
const a = doc.createElement('a');
- a.href = node.props.url;
+ a.setAttribute('href', node.props.url);
a.textContent = node.props.url;
return a;
},
search: (node) => {
const a = doc.createElement('a');
- a.href = `https://www.google.com/search?q=${node.props.query}`;
+ a.setAttribute('href', `https://www.google.com/search?q=${node.props.query}`);
a.textContent = node.props.content;
return a;
},