mirror of
https://github.com/microsoft/vscode.git
synced 2026-05-02 14:31:31 +01:00
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:
@@ -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 + ':');
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user