0
0
Fork 0

Change links in webUI to rewrite misleading links (#11426)

* [WiP] Show host for “misleading” links

* Disallow misleading targets which domain names are prefixes of link text

* Move decodeIDNA to app/javascript/mastodon/utils

* Add support for international domain names

* Change link origin tag color to darker text color

* Handle links to domains starting with www. as shortened by Mastodon

* [WiP] Ignore links that cannot be misread as URLs, rewrite other links
This commit is contained in:
ThibG 2019-07-30 12:13:29 +02:00 committed by Eugen Rochko
parent 78144f4c79
commit b31b232edf
3 changed files with 101 additions and 10 deletions

View file

@ -2,18 +2,9 @@ import React from 'react';
import PropTypes from 'prop-types';
import Immutable from 'immutable';
import ImmutablePropTypes from 'react-immutable-proptypes';
import punycode from 'punycode';
import classnames from 'classnames';
import Icon from 'mastodon/components/icon';
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 'mastodon/utils/idna';
const getHostname = url => {
const parser = document.createElement('a');