diff --git a/ts/test-node/types/LinkPreview_test.ts b/ts/test-node/types/LinkPreview_test.ts index 39bd56e29..44764b07a 100644 --- a/ts/test-node/types/LinkPreview_test.ts +++ b/ts/test-node/types/LinkPreview_test.ts @@ -62,12 +62,6 @@ describe('Link previews', () => { assert.isFalse(shouldLinkifyMessage('\u202e')); }); - it('returns false for strings with unicode drawing characters', () => { - assert.isFalse(shouldLinkifyMessage('\u2500')); - assert.isFalse(shouldLinkifyMessage('\u2588')); - assert.isFalse(shouldLinkifyMessage('\u25FF')); - }); - it('returns true other strings', () => { assert.isTrue(shouldLinkifyMessage(null)); assert.isTrue(shouldLinkifyMessage(undefined)); @@ -166,6 +160,21 @@ describe('Link previews', () => { assert.strictEqual(isLinkSneaky(link), true); }); + it('returns true for strings with unicode drawing characters', () => { + assert.strictEqual( + isLinkSneaky('https://example.com/\u2500/stuff'), + true + ); + assert.strictEqual( + isLinkSneaky('https://example.com/\u2588/stuff'), + true + ); + assert.strictEqual( + isLinkSneaky('https://example.com/\u25FF/stuff'), + true + ); + }); + it('returns true for $', () => { const link = 'r.id$s.id'; assert.strictEqual(isLinkSneaky(link), true); diff --git a/ts/types/LinkPreview.ts b/ts/types/LinkPreview.ts index 6e009e2fd..b75c324a1 100644 --- a/ts/types/LinkPreview.ts +++ b/ts/types/LinkPreview.ts @@ -90,9 +90,6 @@ export function shouldLinkifyMessage( if (DIRECTIONAL_OVERRIDES.test(message)) { return false; } - if (UNICODE_DRAWING.test(message)) { - return false; - } return true; } @@ -187,6 +184,10 @@ export function isLinkSneaky(href: string): boolean { return true; } + if (UNICODE_DRAWING.test(href)) { + return true; + } + const url = maybeParseUrl(href); // If we can't parse it, it's sneaky.