From 51d85e58ebc6f4cee8911bada0808abaaeff0710 Mon Sep 17 00:00:00 2001 From: jojomatik Date: Fri, 17 Sep 2021 10:14:42 -0500 Subject: [PATCH] Linkify additional TLDs See [#5170][0]. [0]: #5170 --- .../conversation/Linkify.stories.tsx | 5 +- ts/components/conversation/Linkify.tsx | 283 +++++++++++++++++- 2 files changed, 282 insertions(+), 6 deletions(-) diff --git a/ts/components/conversation/Linkify.stories.tsx b/ts/components/conversation/Linkify.stories.tsx index a098cad76e..a02d3670ce 100644 --- a/ts/components/conversation/Linkify.stories.tsx +++ b/ts/components/conversation/Linkify.stories.tsx @@ -66,9 +66,10 @@ story.add('Blocked Protocols', () => { return ; }); -story.add('Missing Protocol', () => { +story.add('Missing protocols', () => { const props = createProps({ - text: 'github.com is a place for things', + text: + "I love example.com. I also love кц.рф. I also love مثال.تونس. But I do not love test.example.", }); return ; diff --git a/ts/components/conversation/Linkify.tsx b/ts/components/conversation/Linkify.tsx index d57a8c8139..b9c0412390 100644 --- a/ts/components/conversation/Linkify.tsx +++ b/ts/components/conversation/Linkify.tsx @@ -11,31 +11,306 @@ import { splitByEmoji } from '../../util/emoji'; import { missingCaseError } from '../../util/missingCaseError'; const linkify = LinkifyIt() - // This is all of the TLDs in place in 2010, according to [Wikipedia][0]. Note that - // this only applies to "fuzzy" matches (`example.com`), not matches with - // protocols (`https://example.com`). - // [0]: https://en.wikipedia.org/wiki/Generic_top-level_domain#History + // This is all TLDs in place in 2010, according to [IANA's root zone database][0] + // except for those domains marked as [a test domain][1]. + // + // Note that this only applies to "fuzzy" matches (`example.com`), not matches with + // protocols (`https://example.com`). See [this GitHub comment][2] for more. + // + // [0]: https://www.iana.org/domains/root/db + // [1]: https://www.iana.org/domains/reserved + // [2]: https://github.com/signalapp/Signal-Desktop/issues/4538#issuecomment-748368590 .tlds([ + 'ac', + 'ad', + 'ae', 'aero', + 'af', + 'ag', + 'ai', + 'al', + 'am', + 'an', + 'ao', + 'aq', + 'ar', + 'arpa', + 'as', 'asia', + 'at', + 'au', + 'aw', + 'ax', + 'az', + 'ba', + 'bb', + 'bd', + 'be', + 'bf', + 'bg', + 'bh', + 'bi', 'biz', + 'bj', + 'bl', + 'bm', + 'bn', + 'bo', + 'bq', + 'br', + 'bs', + 'bt', + 'bv', + 'bw', + 'by', + 'bz', + 'ca', 'cat', + 'cc', + 'cd', + 'cf', + 'cg', + 'ch', + 'ci', + 'ck', + 'cl', + 'cm', + 'cn', + 'co', 'com', 'coop', + 'cr', + 'cu', + 'cv', + 'cw', + 'cx', + 'cy', + 'cz', + 'de', + 'dj', + 'dk', + 'dm', + 'do', + 'dz', + 'ec', 'edu', + 'ee', + 'eg', + 'er', + 'es', + 'et', + 'eu', + 'fi', + 'fj', + 'fk', + 'fm', + 'fo', + 'fr', + 'ga', + 'gb', + 'gd', + 'ge', + 'gf', + 'gg', + 'gh', + 'gi', + 'gl', + 'gm', + 'gn', 'gov', + 'gp', + 'gq', + 'gr', + 'gs', + 'gt', + 'gu', + 'gw', + 'gy', + 'hk', + 'hm', + 'hn', + 'hr', + 'ht', + 'hu', + 'id', + 'ie', + 'il', + 'im', + 'in', 'info', 'int', + 'io', + 'iq', + 'ir', + 'is', + 'it', + 'je', + 'jm', + 'jo', 'jobs', + 'jp', + 'ke', + 'kg', + 'kh', + 'ki', + 'km', + 'kn', + 'kp', + 'kr', + 'kw', + 'ky', + 'kz', + 'la', + 'lb', + 'lc', + 'li', + 'lk', + 'lr', + 'ls', + 'lt', + 'lu', + 'lv', + 'ly', + 'ma', + 'mc', + 'md', + 'me', + 'mf', + 'mg', + 'mh', 'mil', + 'mk', + 'ml', + 'mm', + 'mn', + 'mo', 'mobi', + 'mp', + 'mq', + 'mr', + 'ms', + 'mt', + 'mu', 'museum', + 'mv', + 'mw', + 'mx', + 'my', + 'mz', + 'na', 'name', + 'nc', + 'ne', 'net', + 'nf', + 'ng', + 'ni', + 'nl', + 'no', + 'np', + 'nr', + 'nu', + 'nz', + 'om', 'org', + 'pa', + 'pe', + 'pf', + 'pg', + 'ph', + 'pk', + 'pl', + 'pm', + 'pn', + 'pr', 'pro', + 'ps', + 'pt', + 'pw', + 'py', + 'qa', + 're', + 'ro', + 'rs', + 'ru', + 'rw', + 'sa', + 'sb', + 'sc', + 'sd', + 'se', + 'sg', + 'sh', + 'si', + 'sj', + 'sk', + 'sl', + 'sm', + 'sn', + 'so', + 'sr', + 'st', + 'su', + 'sv', + 'sx', + 'sy', + 'sz', + 'tc', + 'td', 'tel', + 'tf', + 'tg', + 'th', + 'tj', + 'tk', + 'tl', + 'tm', + 'tn', + 'to', + 'tp', + 'tr', 'travel', + 'tt', + 'tv', + 'tw', + 'tz', + 'ua', + 'ug', + 'uk', + 'um', + 'us', + 'uy', + 'uz', + 'va', + 'vc', + 've', + 'vg', + 'vi', + 'vn', + 'vu', + 'wf', + 'ws', + '中国', + '中國', + 'ලංකා', + '香港', + '台湾', + '台灣', + 'امارات', + 'الاردن', + 'السعودية', + 'ไทย', + 'рф', + 'تونس', + 'مصر', + 'قطر', + 'இலங்கை', + 'فلسطين', + 'ye', + 'yt', + 'za', + 'zm', + 'zw', ]); export type Props = {