From 0a0aa0e2dbaf345a840b57216906ac52292ae3da Mon Sep 17 00:00:00 2001 From: MeiMei <30769358+mei23@users.noreply.github.com> Date: Tue, 12 Mar 2019 23:38:11 +0900 Subject: Fix #4484 (#4485) * Fix #4484 * import order --- src/misc/convert-host.ts | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 src/misc/convert-host.ts (limited to 'src/misc/convert-host.ts') diff --git a/src/misc/convert-host.ts b/src/misc/convert-host.ts new file mode 100644 index 0000000000..d4478bd85b --- /dev/null +++ b/src/misc/convert-host.ts @@ -0,0 +1,21 @@ +import config from '../config'; +import { toUnicode, toASCII } from 'punycode'; + +export function getFullApAccount(username: string, host: string) { + return host ? `${username}@${toApHost(host)}` : `${username}@${toApHost(config.host)}`; +} + +export function isSelfHost(host: string) { + if (host == null) return true; + return toApHost(config.host) === toApHost(host); +} + +export function toDbHost(host: string) { + if (host == null) return null; + return toUnicode(host.toLowerCase()); +} + +export function toApHost(host: string) { + if (host == null) return null; + return toASCII(host.toLowerCase()); +} -- cgit v1.2.3-freya