diff options
| author | Kagami Sascha Rosylight <saschanaz@outlook.com> | 2023-03-30 02:33:19 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-03-30 09:33:19 +0900 |
| commit | cee1d5e2d01359e6d762a10fc67d4e7c1cc830eb (patch) | |
| tree | 45eab3096b1983ae5267caab4aa4c5eff77b6e5d /packages/misskey-js/src/acct.ts | |
| parent | New Crowdin updates (#10407) (diff) | |
| download | misskey-cee1d5e2d01359e6d762a10fc67d4e7c1cc830eb.tar.gz misskey-cee1d5e2d01359e6d762a10fc67d4e7c1cc830eb.tar.bz2 misskey-cee1d5e2d01359e6d762a10fc67d4e7c1cc830eb.zip | |
chore: integrate misskey-js as a workspace item (git subtree) (#10409)
* Additional changes for the merge
* api-misskey-js
Diffstat (limited to 'packages/misskey-js/src/acct.ts')
| -rw-r--r-- | packages/misskey-js/src/acct.ts | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/packages/misskey-js/src/acct.ts b/packages/misskey-js/src/acct.ts new file mode 100644 index 0000000000..c32cee86c9 --- /dev/null +++ b/packages/misskey-js/src/acct.ts @@ -0,0 +1,14 @@ +export type Acct = { + username: string; + host: string | null; +}; + +export function parse(acct: string): Acct { + if (acct.startsWith('@')) acct = acct.substr(1); + const split = acct.split('@', 2); + return { username: split[0], host: split[1] || null }; +} + +export function toString(acct: Acct): string { + return acct.host == null ? acct.username : `${acct.username}@${acct.host}`; +} |