mirror of
https://github.com/paricafe/misskey.git
synced 2024-11-25 16:36:44 -06:00
22 lines
590 B
TypeScript
22 lines
590 B
TypeScript
import config from '../config';
|
|
import { toASCII } from 'punycode';
|
|
import { URL } from 'url';
|
|
|
|
export function getFullApAccount(username: string, host: string) {
|
|
return host ? `${username}@${toPuny(host)}` : `${username}@${toPuny(config.host)}`;
|
|
}
|
|
|
|
export function isSelfHost(host: string) {
|
|
if (host == null) return true;
|
|
return toPuny(config.host) === toPuny(host);
|
|
}
|
|
|
|
export function extractDbHost(uri: string) {
|
|
const url = new URL(uri);
|
|
return toPuny(url.hostname);
|
|
}
|
|
|
|
export function toPuny(host: string) {
|
|
if (host == null) return null;
|
|
return toASCII(host.toLowerCase());
|
|
}
|