From 5dce81c0dbbd6531ecf927fd3c9a381f6ddbf181 Mon Sep 17 00:00:00 2001 From: MeiMei <30769358+mei23@users.noreply.github.com> Date: Sun, 14 Oct 2018 16:56:19 +0900 Subject: 非ASCIIなドメインへのメンションの修正 (#2903) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * punycodeでされたmentionのラベルをunicodeとして表示する * post-form mentionはpunycodeにする * mentionの表示はURLもAPI向けもunicodeにする --- src/mfm/parse/elements/mention.ts | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'src/mfm/parse/elements') diff --git a/src/mfm/parse/elements/mention.ts b/src/mfm/parse/elements/mention.ts index a95ec00384..ade5954423 100644 --- a/src/mfm/parse/elements/mention.ts +++ b/src/mfm/parse/elements/mention.ts @@ -2,10 +2,12 @@ * Mention */ import parseAcct from '../../../misc/acct/parse'; +import { toUnicode } from 'punycode'; export type TextElementMention = { type: 'mention' content: string + canonical: string username: string host: string }; @@ -15,9 +17,11 @@ export default function(text: string) { if (!match) return null; const mention = match[0]; const { username, host } = parseAcct(mention.substr(1)); + const canonical = host != null ? `@${username}@${toUnicode(host)}` : mention; return { type: 'mention', content: mention, + canonical, username, host } as TextElementMention; -- cgit v1.2.3-freya