From bcb1ad98de0ab2d2b184e030d8a7bcbb1e4e288b Mon Sep 17 00:00:00 2001 From: Paul Frazee Date: Mon, 28 Nov 2022 10:22:08 -0600 Subject: Fix a couple incorrect link detections ('e.g.' and 'foo.jpg') (close #13) --- __tests__/string-utils.ts | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to '__tests__') diff --git a/__tests__/string-utils.ts b/__tests__/string-utils.ts index c677b44d3..fc7a8f272 100644 --- a/__tests__/string-utils.ts +++ b/__tests__/string-utils.ts @@ -31,6 +31,11 @@ describe('extractEntities', () => { 'start middle end.com/foo/bar?baz=bux#hash', 'newline1.com\nnewline2.com', 'not.. a..url ..here', + 'e.g.', + 'something-cool.jpg', + 'website.com.jpg', + 'e.g./foo', + 'website.com.jpg/foo', ] interface Output { type: string @@ -80,6 +85,11 @@ describe('extractEntities', () => { {type: 'link', value: 'newline2.com', noScheme: true}, ], [], + [], + [], + [], + [], + [], ] it('correctly handles a set of text inputs', () => { for (let i = 0; i < inputs.length; i++) { @@ -145,6 +155,12 @@ describe('detectLinkables', () => { 'start middle end.com/foo/bar?baz=bux#hash', 'newline1.com\nnewline2.com', 'not.. a..url ..here', + 'e.g.', + 'e.g. real.com fake.notreal', + 'something-cool.jpg', + 'website.com.jpg', + 'e.g./foo', + 'website.com.jpg/foo', ] const outputs = [ ['no linkable'], @@ -171,6 +187,12 @@ describe('detectLinkables', () => { ['start middle ', {link: 'end.com/foo/bar?baz=bux#hash'}], [{link: 'newline1.com'}, '\n', {link: 'newline2.com'}], ['not.. a..url ..here'], + ['e.g.'], + ['e.g. ', {link: 'real.com'}, ' fake.notreal'], + ['something-cool.jpg'], + ['website.com.jpg'], + ['e.g./foo'], + ['website.com.jpg/foo'], ] it('correctly handles a set of text inputs', () => { for (let i = 0; i < inputs.length; i++) { -- cgit 1.4.1