mirror of
https://github.com/ilyakooo0/urbit.git
synced 2024-12-02 15:13:25 +03:00
tokenizeMessage: ignore commas and dots that end a url
This commit is contained in:
parent
001ff8becc
commit
93c968d9fa
@ -1,7 +1,7 @@
|
||||
import urbitOb from 'urbit-ob';
|
||||
import { parsePermalink, permalinkToReference } from '~/logic/lib/permalinks';
|
||||
|
||||
const URL_REGEX = new RegExp(String(/^([^[\]]*?)(([\w\-\+]+:\/\/)[-a-zA-Z0-9:@;?&=\/%\+\.\*!'\(\),\$_\{\}\^~\[\]`#|]+)([\s\S]*)/.source));
|
||||
const URL_REGEX = new RegExp(String(/^([^[\]]*?)(([\w\-\+]+:\/\/)[-a-zA-Z0-9:@;?&=\/%\+\.\*!'\(\),\$_\{\}\^~\[\]`#|]+[-a-zA-Z0-9:@;?&=\/%\+\*!'\(\)\$_\{\}\^~\[\]`#|])([\s\S]*)/.source));
|
||||
|
||||
const PATP_REGEX = /^([\s\S]*?)(~[a-z_-]+)([\s\S]*)/;
|
||||
|
||||
|
@ -100,4 +100,17 @@ describe('tokenizeMessage', () => {
|
||||
expect(text).toBe('test ');
|
||||
expect(url).toBe('https://en.wikipedia.org/wiki/Turbo_(gastropod)');
|
||||
});
|
||||
it('should ignore ending commas', () => {
|
||||
const example = 'https://tlon.io/test, foo';
|
||||
const [{ url }, { text }] = tokenizeMessage(example);
|
||||
expect(text).toBe(', foo');
|
||||
expect(url).toBe('https://tlon.io/test');
|
||||
});
|
||||
|
||||
it('should ignore ending dots', () => {
|
||||
const example = 'https://tlon.io/test. foo';
|
||||
const [{ url }, { text }] = tokenizeMessage(example);
|
||||
expect(text).toBe('. foo');
|
||||
expect(url).toBe('https://tlon.io/test');
|
||||
});
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user