mirror of
https://github.com/glitch-soc/mastodon.git
synced 2025-12-14 16:28:59 +00:00
15 lines
293 B
TypeScript
15 lines
293 B
TypeScript
import punycode from 'punycode/';
|
|
|
|
const IDNA_PREFIX = 'xn--';
|
|
|
|
export const decode = (domain: string) => {
|
|
return domain
|
|
.split('.')
|
|
.map((part) =>
|
|
part.startsWith(IDNA_PREFIX)
|
|
? punycode.decode(part.slice(IDNA_PREFIX.length))
|
|
: part,
|
|
)
|
|
.join('.');
|
|
};
|