0
0
Fork 0
mirror of https://github.com/lunaisnotaboy/mastodon.git synced 2024-12-16 02:15:14 +00:00
mastodon/app/javascript/flavours/glitch/util/idna.js

11 lines
255 B
JavaScript

import punycode from 'punycode';
const IDNA_PREFIX = 'xn--';
export const decode = domain => {
return domain
.split('.')
.map(part => part.indexOf(IDNA_PREFIX) === 0 ? punycode.decode(part.slice(IDNA_PREFIX.length)) : part)
.join('.');
};