From 7fe937026bb52377c735dba58335a647781406e7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Acid=20Chicken=20=28=E7=A1=AB=E9=85=B8=E9=B6=8F=29?= Date: Thu, 13 Dec 2018 01:33:18 +0900 Subject: [PATCH] Update html.ts (#3603) --- src/mfm/html.ts | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/mfm/html.ts b/src/mfm/html.ts index 66617adf9..8712add05 100644 --- a/src/mfm/html.ts +++ b/src/mfm/html.ts @@ -103,8 +103,18 @@ export default (tokens: Node[], mentionedRemoteUsers: INote['mentionedRemoteUser mention(token) { const a = doc.createElement('a'); const { username, host, acct } = token.props; - const remoteUserInfo = mentionedRemoteUsers.find(remoteUser => remoteUser.username === username && remoteUser.host === host); - a.href = remoteUserInfo ? remoteUserInfo.uri : `${config.url}/${acct}`; + switch (host) { + case 'github.com': + a.href = `https://github.com/${username}`; + break; + case 'twitter.com': + a.href = `https://twitter.com/${username}`; + break; + default: + const remoteUserInfo = mentionedRemoteUsers.find(remoteUser => remoteUser.username === username && remoteUser.host === host); + a.href = remoteUserInfo ? remoteUserInfo.uri : `${config.url}/${acct}`; + break; + } a.textContent = acct; return a; },