[MFM] Improve URL parsing

Fix #3368
This commit is contained in:
syuilo 2018-11-22 05:02:38 +09:00
parent 67df681a48
commit 8cbb961493
No known key found for this signature in database
GPG key ID: BDC4C49D06AB9D69
2 changed files with 46 additions and 10 deletions

View file

@ -381,6 +381,15 @@ describe('Text', () => {
], tokens);
});
it('ignore parent brackets 2', () => {
const tokens = analyze('(foo https://example.com/foo)');
assert.deepEqual([
text('(foo '),
node('url', { url: 'https://example.com/foo' }),
text(')')
], tokens);
});
it('ignore parent brackets with internal brackets', () => {
const tokens = analyze('(https://example.com/foo(bar))');
assert.deepEqual([
@ -391,13 +400,26 @@ describe('Text', () => {
});
});
it('link', () => {
const tokens = analyze('[foo](https://example.com)');
assert.deepEqual([
nodeWithChildren('link', [
text('foo')
], { url: 'https://example.com', silent: false })
], tokens);
describe('link', () => {
it('simple', () => {
const tokens = analyze('[foo](https://example.com)');
assert.deepEqual([
nodeWithChildren('link', [
text('foo')
], { url: 'https://example.com', silent: false })
], tokens);
});
it('in text', () => {
const tokens = analyze('before[foo](https://example.com)after');
assert.deepEqual([
text('before'),
nodeWithChildren('link', [
text('foo')
], { url: 'https://example.com', silent: false }),
text('after'),
], tokens);
});
});
it('emoji', () => {