~cytrogen/masto-fe

ref: f89f3a85662ce1f4e6f130748ded22821e4a7acd masto-fe/app/javascript/flavours/glitch/utils/idna.js -rw-r--r-- 255 bytes
f89f3a85 — Claire Fix glitch-soc's thread line styling (#2214) 2 years ago
                                                                                
1
2
3
4
5
6
7
8
9
10
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('.');
};