/.well-known 周りをいい感じに (#4141)

* Enhance /.well-known and their friends

* Fix bug
This commit is contained in:
Acid Chicken (硫酸鶏)
2019-02-05 17:42:55 +09:00
committed by GitHub
parent 2f4434b0d8
commit 9dd06a7621
9 changed files with 202 additions and 89 deletions

View File

@ -1,4 +1,6 @@
export default (acct: string) => {
import Acct from './type';
export default (acct: string): Acct => {
if (acct.startsWith('@')) acct = acct.substr(1);
const split = acct.split('@', 2);
return { username: split[0], host: split[1] || null };

View File

@ -1,8 +1,5 @@
type UserLike = {
host: string;
username: string;
};
import Acct from './type';
export default (user: UserLike) => {
export default (user: Acct) => {
return user.host === null ? user.username : `${user.username}@${user.host}`;
};

6
src/misc/acct/type.ts Normal file
View File

@ -0,0 +1,6 @@
type Acct = {
username: string;
host: string;
};
export default Acct;