parent
c56b94ae96
commit
0a0aa0e2db
7 changed files with 35 additions and 14 deletions
21
src/misc/convert-host.ts
Normal file
21
src/misc/convert-host.ts
Normal file
|
@ -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());
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue