Merge pull request #184608 from microsoft/tyriar/183958

Exclude query strings from detected local links
This commit is contained in:
Daniel Imms 2023-06-08 08:53:18 -07:00 committed by GitHub
commit fef218690d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 34 additions and 1 deletions

View file

@ -293,7 +293,7 @@ enum RegexPathConstants {
PathSeparatorClause = '\\/',
// '":; are allowed in paths but they are often separators so ignore them
// Also disallow \\ to prevent a catastropic backtracking case #24795
ExcludedPathCharactersClause = '[^\\0<>\\s!`&*()\'":;\\\\]',
ExcludedPathCharactersClause = '[^\\0<>\\?\\s!`&*()\'":;\\\\]',
ExcludedStartPathCharactersClause = '[^\\0<>\\s!`&*()\\[\\]\'":;\\\\]',
WinOtherPathPrefix = '\\.\\.?|\\~',

View file

@ -478,6 +478,39 @@ suite('TerminalLinkParsing', () => {
}
});
suite('query strings', () => {
for (const os of operatingSystems) {
test(`should exclude query strings from link paths ${osLabel[os]}`, () => {
deepStrictEqual(
detectLinks(`${osTestPath[os]}?a=b`, os),
[
{
path: {
index: 0,
text: osTestPath[os]
},
prefix: undefined,
suffix: undefined
}
] as IParsedLink[]
);
deepStrictEqual(
detectLinks(`${osTestPath[os]}?a=b&c=d`, os),
[
{
path: {
index: 0,
text: osTestPath[os]
},
prefix: undefined,
suffix: undefined
}
] as IParsedLink[]
);
});
}
});
suite('should detect file names in git diffs', () => {
test('--- a/foo/bar', () => {
deepStrictEqual(