mirror of
https://github.com/microsoft/vscode.git
synced 2026-04-22 17:48:56 +01:00
Error if registering an unsupported scheme for external opener
Fixes #115168
This commit is contained in:
@@ -5,6 +5,7 @@
|
||||
|
||||
import { CancellationToken } from 'vs/base/common/cancellation';
|
||||
import { toDisposable } from 'vs/base/common/lifecycle';
|
||||
import { Schemas } from 'vs/base/common/network';
|
||||
import { URI, UriComponents } from 'vs/base/common/uri';
|
||||
import * as modes from 'vs/editor/common/modes';
|
||||
import { ExtensionIdentifier } from 'vs/platform/extensions/common/extensions';
|
||||
@@ -14,6 +15,8 @@ import { ExtHostUriOpenersShape, IMainContext, MainContext, MainThreadUriOpeners
|
||||
|
||||
export class ExtHostUriOpeners implements ExtHostUriOpenersShape {
|
||||
|
||||
private static readonly supportedSchemes = new Set<string>([Schemas.http, Schemas.https]);
|
||||
|
||||
private readonly _proxy: MainThreadUriOpenersShape;
|
||||
|
||||
private readonly _openers = new Map<string, vscode.ExternalUriOpener>();
|
||||
@@ -24,7 +27,7 @@ export class ExtHostUriOpeners implements ExtHostUriOpenersShape {
|
||||
this._proxy = mainContext.getProxy(MainContext.MainThreadUriOpeners);
|
||||
}
|
||||
|
||||
registerUriOpener(
|
||||
registerExternalUriOpener(
|
||||
extensionId: ExtensionIdentifier,
|
||||
id: string,
|
||||
opener: vscode.ExternalUriOpener,
|
||||
@@ -34,6 +37,11 @@ export class ExtHostUriOpeners implements ExtHostUriOpenersShape {
|
||||
throw new Error(`Opener with id '${id}' already registered`);
|
||||
}
|
||||
|
||||
const invalidScheme = metadata.schemes.find(scheme => !ExtHostUriOpeners.supportedSchemes.has(scheme));
|
||||
if (invalidScheme) {
|
||||
throw new Error(`Scheme '${invalidScheme}' is not supported. Only http and https are currently supported.`);
|
||||
}
|
||||
|
||||
this._openers.set(id, opener);
|
||||
this._proxy.$registerUriOpener(id, metadata.schemes, extensionId, metadata.label);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user