Don't linkify when certain unicode formatting characters are present
This commit is contained in:
parent
e62606361d
commit
006de5b1a5
3 changed files with 50 additions and 1 deletions
|
@ -5,6 +5,7 @@ import { assert } from 'chai';
|
|||
|
||||
import {
|
||||
findLinks,
|
||||
shouldLinkifyMessage,
|
||||
shouldPreviewHref,
|
||||
isLinkSneaky,
|
||||
} from '../../types/LinkPreview';
|
||||
|
@ -44,6 +45,26 @@ describe('Link previews', () => {
|
|||
});
|
||||
});
|
||||
|
||||
describe('#shouldLinkifyMessage;', () => {
|
||||
it('returns false for strings with directional override characters', () => {
|
||||
assert.isFalse(shouldLinkifyMessage('\u202c'));
|
||||
assert.isFalse(shouldLinkifyMessage('\u202d'));
|
||||
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));
|
||||
assert.isTrue(shouldLinkifyMessage('Random other string aqu%C3%AD'));
|
||||
});
|
||||
});
|
||||
|
||||
describe('#findLinks', () => {
|
||||
it('returns all links if no caretLocation is provided', () => {
|
||||
const text =
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue