From 33a9783ae5cf18e913cfe3f0223ed89aa94e63b4 Mon Sep 17 00:00:00 2001 From: syuilo Date: Tue, 9 Apr 2019 23:59:32 +0900 Subject: ドメインは常にPunycodeで保存するように MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/misc/acct/render.ts | 2 +- src/misc/convert-host.ts | 15 +++++---------- 2 files changed, 6 insertions(+), 11 deletions(-) (limited to 'src/misc') diff --git a/src/misc/acct/render.ts b/src/misc/acct/render.ts index 67e063fcb3..094eceffe9 100644 --- a/src/misc/acct/render.ts +++ b/src/misc/acct/render.ts @@ -1,5 +1,5 @@ import Acct from './type'; export default (user: Acct) => { - return user.host === null ? user.username : `${user.username}@${user.host}`; + return user.host == null ? user.username : `${user.username}@${user.host}`; }; diff --git a/src/misc/convert-host.ts b/src/misc/convert-host.ts index 8f2f1c7aba..f7feebd55c 100644 --- a/src/misc/convert-host.ts +++ b/src/misc/convert-host.ts @@ -1,27 +1,22 @@ import config from '../config'; -import { toUnicode, toASCII } from 'punycode'; +import { toASCII } from 'punycode'; import { URL } from 'url'; export function getFullApAccount(username: string, host: string) { - return host ? `${username}@${toApHost(host)}` : `${username}@${toApHost(config.host)}`; + return host ? `${username}@${toPuny(host)}` : `${username}@${toPuny(config.host)}`; } export function isSelfHost(host: string) { if (host == null) return true; - return toApHost(config.host) === toApHost(host); + return toPuny(config.host) === toPuny(host); } export function extractDbHost(uri: string) { const url = new URL(uri); - return toDbHost(url.hostname); + return toPuny(url.hostname); } -export function toDbHost(host: string) { - if (host == null) return null; - return toUnicode(host.toLowerCase()); -} - -export function toApHost(host: string) { +export function toPuny(host: string) { if (host == null) return null; return toASCII(host.toLowerCase()); } -- cgit v1.2.3-freya