glitch-soc/mastodon

View on GitHub
app/javascript/flavours/glitch/utils/idna.js

Summary

Maintainability
A
2 hrs
Test Coverage
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('.');
};