forked from mastodon/mastodon
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Change links in webUI to rewrite misleading links (mastodon#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
- Loading branch information
1 parent
78144f4
commit b31b232
Showing
3 changed files
with
101 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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('.'); | ||
}; |