Clean up document link resolve (#154959)

- Move vscode scheme normalization to the DocumentLinkProvider
- Remove extra function since we already recognize uri-like links
This commit is contained in:
Matt Bierner
2022-07-12 15:55:21 -07:00
committed by GitHub
parent 66d8947f84
commit 75e231ad82
2 changed files with 6 additions and 27 deletions

View File

@@ -3,33 +3,15 @@
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import * as vscode from 'vscode';
export const Schemes = Object.freeze({
http: 'http',
https: 'https',
file: 'file',
untitled: 'untitled',
mailto: 'mailto',
data: 'data',
vscode: 'vscode',
'vscode-insiders': 'vscode-insiders',
notebookCell: 'vscode-notebook-cell',
});
const knownSchemes = [
...Object.values(Schemes),
`${vscode.env.uriScheme}`
];
export function getUriForLinkWithKnownExternalScheme(link: string): vscode.Uri | undefined {
if (knownSchemes.some(knownScheme => isOfScheme(knownScheme, link))) {
return vscode.Uri.parse(link);
}
return undefined;
}
export function isOfScheme(scheme: string, link: string): boolean {
return link.toLowerCase().startsWith(scheme + ':');
}