Fix MFM URL parsing
This commit is contained in:
parent
63c659bc8f
commit
285d0d13f9
@ -164,8 +164,10 @@ export const mfmLanguage = P.createLanguage({
|
|||||||
} else
|
} else
|
||||||
url = match[0];
|
url = match[0];
|
||||||
url = removeOrphanedBrackets(url);
|
url = removeOrphanedBrackets(url);
|
||||||
if (url.endsWith('.')) url = url.substr(0, url.lastIndexOf('.'));
|
while (url.endsWith('.') || url.endsWith(',')) {
|
||||||
if (url.endsWith(',')) url = url.substr(0, url.lastIndexOf(','));
|
if (url.endsWith('.')) url = url.substr(0, url.lastIndexOf('.'));
|
||||||
|
if (url.endsWith(',')) url = url.substr(0, url.lastIndexOf(','));
|
||||||
|
}
|
||||||
return P.makeSuccess(i + url.length, url);
|
return P.makeSuccess(i + url.length, url);
|
||||||
}).map(x => createLeaf('url', { url: x }));
|
}).map(x => createLeaf('url', { url: x }));
|
||||||
},
|
},
|
||||||
|
@ -804,6 +804,14 @@ describe('MFM', () => {
|
|||||||
]);
|
]);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('ignore trailing periods', () => {
|
||||||
|
const tokens = parse('https://example.com...');
|
||||||
|
assert.deepStrictEqual(tokens, [
|
||||||
|
leaf('url', { url: 'https://example.com' }),
|
||||||
|
text('...')
|
||||||
|
]);
|
||||||
|
});
|
||||||
|
|
||||||
it('with comma', () => {
|
it('with comma', () => {
|
||||||
const tokens = parse('https://example.com/foo?bar=a,b');
|
const tokens = parse('https://example.com/foo?bar=a,b');
|
||||||
assert.deepStrictEqual(tokens, [
|
assert.deepStrictEqual(tokens, [
|
||||||
|
Loading…
Reference in New Issue
Block a user