Move decodeIDNA to app/javascript/flavours/glitch/util

lolsob-rspec
Thibaut Girka 2019-08-01 14:35:17 +02:00 committed by ThibG
parent 00bc284cfc
commit d84045c9ca
2 changed files with 11 additions and 9 deletions

View File

@ -4,15 +4,7 @@ import Immutable from 'immutable';
import ImmutablePropTypes from 'react-immutable-proptypes';
import punycode from 'punycode';
import classnames from 'classnames';
const IDNA_PREFIX = 'xn--';
const decodeIDNA = domain => {
return domain
.split('.')
.map(part => part.indexOf(IDNA_PREFIX) === 0 ? punycode.decode(part.slice(IDNA_PREFIX.length)) : part)
.join('.');
};
import { decode as decodeIDNA } from 'flavours/glitch/util/idna';
const getHostname = url => {
const parser = document.createElement('a');

View File

@ -0,0 +1,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('.');
};