mirror of
https://iceshrimp.dev/crimekillz/iceshrimp-161sh.git
synced 2024-11-24 13:09:07 +01:00
4d341c5918
* wip * wip * wip * wip * wip * Update define.ts * Update update.ts * Update user.ts * wip * wip * Update request.ts * URL * wip * wip * wip * wip * Update invite.ts * Update create.ts
27 lines
717 B
TypeScript
27 lines
717 B
TypeScript
import { URL } from 'url';
|
|
import config from '@/config';
|
|
import { toASCII } from 'punycode';
|
|
|
|
export function getFullApAccount(username: string, host: string | null) {
|
|
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) {
|
|
return toASCII(host.toLowerCase());
|
|
}
|
|
|
|
export function toPunyNullable(host: string | null | undefined): string | null {
|
|
if (host == null) return null;
|
|
return toASCII(host.toLowerCase());
|
|
}
|