未验证 提交 abf3b9d0 编写于 作者: J Joao Moreno

continuation of #91442

上级 bde129b1
......@@ -23,7 +23,7 @@ export class LinkedText {
}
}
const LINK_REGEX = /\[([^\]]+)\]\(((?:https?:\/\/|command:)[^\)\s]+)(?: (?:"|')([^"]+)(?:"|'))?\)/gi;
const LINK_REGEX = /\[([^\]]+)\]\(((?:https?:\/\/|command:)[^\)\s]+)(?: ("|')([^\3]+)(\3))?\)/gi;
export function parseLinkedText(text: string): LinkedText {
const result: LinkedTextNode[] = [];
......@@ -36,7 +36,7 @@ export function parseLinkedText(text: string): LinkedText {
result.push(text.substring(index, match.index));
}
const [, label, href, title] = match;
const [, label, href, , title] = match;
if (title) {
result.push({ label, href, title });
......
......@@ -26,6 +26,16 @@ suite('LinkedText', () => {
{ label: 'link text', href: 'http://link.href', title: 'and a title' },
'.'
]);
assert.deepEqual(parseLinkedText('Some message with [link text](http://link.href "and a \'title\'").').nodes, [
'Some message with ',
{ label: 'link text', href: 'http://link.href', title: 'and a \'title\'' },
'.'
]);
assert.deepEqual(parseLinkedText('Some message with [link text](http://link.href \'and a "title"\').').nodes, [
'Some message with ',
{ label: 'link text', href: 'http://link.href', title: 'and a "title"' },
'.'
]);
assert.deepEqual(parseLinkedText('Some message with [link text](random stuff).').nodes, [
'Some message with [link text](random stuff).'
]);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册