This commit is contained in:
MeiMei
2019-03-13 11:21:16 +09:00
committed by syuilo
parent f5be8fd313
commit 69a0d9034f
4 changed files with 35 additions and 1 deletions

View File

@ -1,5 +1,6 @@
import config from '../config';
import { toUnicode, toASCII } from 'punycode';
import { URL } from 'url';
export function getFullApAccount(username: string, host: string) {
return host ? `${username}@${toApHost(host)}` : `${username}@${toApHost(config.host)}`;
@ -10,6 +11,11 @@ export function isSelfHost(host: string) {
return toApHost(config.host) === toApHost(host);
}
export function extractDbHost(uri: string) {
const url = new URL(uri);
return toDbHost(url.hostname);
}
export function toDbHost(host: string) {
if (host == null) return null;
return toUnicode(host.toLowerCase());