mirror of
https://framagit.org/tykayn/mastodon.git
synced 2023-08-25 08:33:12 +02:00
11 lines
255 B
JavaScript
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('.');
|
||
|
};
|