Skip to content
Snippets Groups Projects
Unverified Commit 76693138 authored by syuilo's avatar syuilo
Browse files

Fix MFM parsing: Ignore parent [] of URL

parent 10677b57
No related branches found
No related tags found
No related merge requests found
......@@ -6,8 +6,8 @@ import { toUnicode } from 'punycode';
import { emojiRegex } from '../misc/emoji-regex';
export function removeOrphanedBrackets(s: string): string {
const openBrackets = ['(', ''];
const closeBrackets = [')', ''];
const openBrackets = ['(', '', '['];
const closeBrackets = [')', '', ']'];
const xs = cumulativeSum(s.split('').map(c => {
if (openBrackets.includes(c)) return 1;
if (closeBrackets.includes(c)) return -1;
......
......@@ -843,6 +843,15 @@ describe('MFM', () => {
]);
});
it('ignore parent []', () => {
const tokens = parse('[https://example.com/foo]');
assert.deepStrictEqual(tokens, [
text('['),
leaf('url', { url: 'https://example.com/foo' }),
text(']')
]);
});
it('ignore parent brackets 2', () => {
const tokens = parse('(foo https://example.com/foo)');
assert.deepStrictEqual(tokens, [
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment