mirror of
https://github.com/Microsoft/vscode
synced 2024-08-27 21:09:43 +00:00
Links with no authority are considered invalid (#189323)
* edit validateLink
This commit is contained in:
parent
f7d59ef171
commit
ed59945156
|
@ -57,7 +57,7 @@ export function validateLink(urlList: string): { isValid: boolean; cleanedUrlLis
|
|||
}
|
||||
const splitUrlList = trimmedUrlList.split(' ').filter(item => item !== ''); //split on spaces and remove empty strings
|
||||
if (uri) {
|
||||
isValid = splitUrlList.length === 1 && !splitUrlList[0].includes('\n') && externalUriSchemes.includes(vscode.Uri.parse(splitUrlList[0]).scheme);
|
||||
isValid = splitUrlList.length === 1 && !splitUrlList[0].includes('\n') && externalUriSchemes.includes(vscode.Uri.parse(splitUrlList[0]).scheme) && !!vscode.Uri.parse(splitUrlList[0]).authority;
|
||||
}
|
||||
return { isValid, cleanedUrlList: splitUrlList[0] };
|
||||
}
|
||||
|
|
|
@ -94,6 +94,11 @@ suite('createEditAddingLinksForUriList', () => {
|
|||
const isLink = validateLink('https://www.microsoft.com/ \r\nhttps://www.microsoft.com/\r\nhttps://www.microsoft.com/\r\n hello \r\nhttps://www.microsoft.com/').isValid;
|
||||
assert.strictEqual(isLink, false);
|
||||
});
|
||||
|
||||
test('Markdown pasting should not occur for just a valid uri scheme', () => {
|
||||
const isLink = validateLink('https://').isValid;
|
||||
assert.strictEqual(isLink, false);
|
||||
});
|
||||
});
|
||||
|
||||
suite('appendToLinkSnippet', () => {
|
||||
|
|
Loading…
Reference in a new issue