Path: blob/main/src/vs/workbench/contrib/externalUriOpener/common/configuration.ts
4780 views
/*---------------------------------------------------------------------------------------------1* Copyright (c) Microsoft Corporation. All rights reserved.2* Licensed under the MIT License. See License.txt in the project root for license information.3*--------------------------------------------------------------------------------------------*/45import { IConfigurationNode, IConfigurationRegistry, Extensions } from '../../../../platform/configuration/common/configurationRegistry.js';6import { workbenchConfigurationNodeBase } from '../../../common/configuration.js';7import * as nls from '../../../../nls.js';8import { IJSONSchema } from '../../../../base/common/jsonSchema.js';9import { Registry } from '../../../../platform/registry/common/platform.js';1011export const defaultExternalUriOpenerId = 'default';1213export const externalUriOpenersSettingId = 'workbench.externalUriOpeners';1415export interface ExternalUriOpenersConfiguration {16readonly [uriGlob: string]: string;17}1819const externalUriOpenerIdSchemaAddition: IJSONSchema = {20type: 'string',21enum: []22};2324const exampleUriPatterns = `25- \`https://microsoft.com\`: Matches this specific domain using https26- \`https://microsoft.com:8080\`: Matches this specific domain on this port using https27- \`https://microsoft.com:*\`: Matches this specific domain on any port using https28- \`https://microsoft.com/foo\`: Matches \`https://microsoft.com/foo\` and \`https://microsoft.com/foo/bar\`, but not \`https://microsoft.com/foobar\` or \`https://microsoft.com/bar\`29- \`https://*.microsoft.com\`: Match all domains ending in \`microsoft.com\` using https30- \`microsoft.com\`: Match this specific domain using either http or https31- \`*.microsoft.com\`: Match all domains ending in \`microsoft.com\` using either http or https32- \`http://192.168.0.1\`: Matches this specific IP using http33- \`http://192.168.0.*\`: Matches all IP's with this prefix using http34- \`*\`: Match all domains using either http or https`;3536export const externalUriOpenersConfigurationNode: IConfigurationNode = {37...workbenchConfigurationNodeBase,38properties: {39[externalUriOpenersSettingId]: {40type: 'object',41markdownDescription: nls.localize('externalUriOpeners', "Configure the opener to use for external URIs (http, https)."),42defaultSnippets: [{43body: {44'example.com': '$1'45}46}],47additionalProperties: {48anyOf: [49{50type: 'string',51markdownDescription: nls.localize('externalUriOpeners.uri', "Map URI pattern to an opener id.\nExample patterns: \n{0}", exampleUriPatterns),52},53{54type: 'string',55markdownDescription: nls.localize('externalUriOpeners.uri', "Map URI pattern to an opener id.\nExample patterns: \n{0}", exampleUriPatterns),56enum: [defaultExternalUriOpenerId],57enumDescriptions: [nls.localize('externalUriOpeners.defaultId', "Open using VS Code's standard opener.")],58},59externalUriOpenerIdSchemaAddition60]61}62}63}64};6566export function updateContributedOpeners(enumValues: string[], enumDescriptions: string[]): void {67externalUriOpenerIdSchemaAddition.enum = enumValues;68externalUriOpenerIdSchemaAddition.enumDescriptions = enumDescriptions;6970Registry.as<IConfigurationRegistry>(Extensions.Configuration)71.notifyConfigurationSchemaUpdated(externalUriOpenersConfigurationNode);72}737475