diff options
author | Thibaut Girka <thib@sitedethib.com> | 2019-08-01 14:35:17 +0200 |
---|---|---|
committer | ThibG <thib@sitedethib.com> | 2019-08-04 22:25:56 +0200 |
commit | 49a28e69a520d5994352e231e9879a5093af5916 (patch) | |
tree | 42157ed4eaef2c3aa1d87c3645ea6361c3cd9dad | |
parent | 4ecfa8f298399d9857737f212fc8f5767ffa7c6d (diff) |
Move decodeIDNA to app/javascript/flavours/glitch/util
-rw-r--r-- | app/javascript/flavours/glitch/features/status/components/card.js | 10 | ||||
-rw-r--r-- | app/javascript/flavours/glitch/util/idna.js | 10 |
2 files changed, 11 insertions, 9 deletions
diff --git a/app/javascript/flavours/glitch/features/status/components/card.js b/app/javascript/flavours/glitch/features/status/components/card.js index f974a87a1..108b6e3b2 100644 --- a/app/javascript/flavours/glitch/features/status/components/card.js +++ b/app/javascript/flavours/glitch/features/status/components/card.js @@ -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'); diff --git a/app/javascript/flavours/glitch/util/idna.js b/app/javascript/flavours/glitch/util/idna.js new file mode 100644 index 000000000..efab5bacf --- /dev/null +++ b/app/javascript/flavours/glitch/util/idna.js @@ -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('.'); +}; |