mirror of
https://activitypub.software/TransFem-org/Sharkey.git
synced 2024-11-16 12:46:42 +01:00
22 lines
594 B
TypeScript
22 lines
594 B
TypeScript
|
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());
|
||
|
}
|