mirror of
https://github.com/microsoft/vscode.git
synced 2026-04-23 01:58:53 +01:00
Improve markdown link regexp (#152533)
* Improve markdown link regexp This makes the markdown link regexp more readable and also combines the two regular expressions we were running * Fixed backtracking
This commit is contained in:
@@ -32,7 +32,7 @@ function assertLinksEqual(actualLinks: readonly vscode.DocumentLink[], expectedR
|
||||
}
|
||||
}
|
||||
|
||||
suite('markdown.DocumentLinkProvider', () => {
|
||||
suite('Markdown: DocumentLinkProvider', () => {
|
||||
test('Should not return anything for empty document', async () => {
|
||||
const links = await getLinksForFile('');
|
||||
assert.strictEqual(links.length, 0);
|
||||
@@ -131,24 +131,24 @@ suite('markdown.DocumentLinkProvider', () => {
|
||||
{
|
||||
const links = await getLinksForFile('[](https://example.com)');
|
||||
assertLinksEqual(links, [
|
||||
new vscode.Range(0, 25, 0, 44),
|
||||
new vscode.Range(0, 13, 0, 22),
|
||||
new vscode.Range(0, 25, 0, 44)
|
||||
]);
|
||||
}
|
||||
{
|
||||
const links = await getLinksForFile('[]( https://whitespace.com )');
|
||||
assertLinksEqual(links, [
|
||||
new vscode.Range(0, 26, 0, 48),
|
||||
new vscode.Range(0, 7, 0, 21),
|
||||
new vscode.Range(0, 26, 0, 48)
|
||||
]);
|
||||
}
|
||||
{
|
||||
const links = await getLinksForFile('[](file1.txt) text [](file2.txt)');
|
||||
assertLinksEqual(links, [
|
||||
new vscode.Range(0, 6, 0, 14),
|
||||
new vscode.Range(0, 17, 0, 26),
|
||||
new vscode.Range(0, 39, 0, 47),
|
||||
new vscode.Range(0, 6, 0, 14),
|
||||
new vscode.Range(0, 50, 0, 59),
|
||||
new vscode.Range(0, 39, 0, 47),
|
||||
]);
|
||||
}
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user