Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
microsoft
GitHub Repository: microsoft/vscode
Path: blob/main/src/vs/workbench/contrib/externalUriOpener/common/configuration.ts
4780 views
1
/*---------------------------------------------------------------------------------------------
2
* Copyright (c) Microsoft Corporation. All rights reserved.
3
* Licensed under the MIT License. See License.txt in the project root for license information.
4
*--------------------------------------------------------------------------------------------*/
5
6
import { IConfigurationNode, IConfigurationRegistry, Extensions } from '../../../../platform/configuration/common/configurationRegistry.js';
7
import { workbenchConfigurationNodeBase } from '../../../common/configuration.js';
8
import * as nls from '../../../../nls.js';
9
import { IJSONSchema } from '../../../../base/common/jsonSchema.js';
10
import { Registry } from '../../../../platform/registry/common/platform.js';
11
12
export const defaultExternalUriOpenerId = 'default';
13
14
export const externalUriOpenersSettingId = 'workbench.externalUriOpeners';
15
16
export interface ExternalUriOpenersConfiguration {
17
readonly [uriGlob: string]: string;
18
}
19
20
const externalUriOpenerIdSchemaAddition: IJSONSchema = {
21
type: 'string',
22
enum: []
23
};
24
25
const exampleUriPatterns = `
26
- \`https://microsoft.com\`: Matches this specific domain using https
27
- \`https://microsoft.com:8080\`: Matches this specific domain on this port using https
28
- \`https://microsoft.com:*\`: Matches this specific domain on any port using https
29
- \`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\`
30
- \`https://*.microsoft.com\`: Match all domains ending in \`microsoft.com\` using https
31
- \`microsoft.com\`: Match this specific domain using either http or https
32
- \`*.microsoft.com\`: Match all domains ending in \`microsoft.com\` using either http or https
33
- \`http://192.168.0.1\`: Matches this specific IP using http
34
- \`http://192.168.0.*\`: Matches all IP's with this prefix using http
35
- \`*\`: Match all domains using either http or https`;
36
37
export const externalUriOpenersConfigurationNode: IConfigurationNode = {
38
...workbenchConfigurationNodeBase,
39
properties: {
40
[externalUriOpenersSettingId]: {
41
type: 'object',
42
markdownDescription: nls.localize('externalUriOpeners', "Configure the opener to use for external URIs (http, https)."),
43
defaultSnippets: [{
44
body: {
45
'example.com': '$1'
46
}
47
}],
48
additionalProperties: {
49
anyOf: [
50
{
51
type: 'string',
52
markdownDescription: nls.localize('externalUriOpeners.uri', "Map URI pattern to an opener id.\nExample patterns: \n{0}", exampleUriPatterns),
53
},
54
{
55
type: 'string',
56
markdownDescription: nls.localize('externalUriOpeners.uri', "Map URI pattern to an opener id.\nExample patterns: \n{0}", exampleUriPatterns),
57
enum: [defaultExternalUriOpenerId],
58
enumDescriptions: [nls.localize('externalUriOpeners.defaultId', "Open using VS Code's standard opener.")],
59
},
60
externalUriOpenerIdSchemaAddition
61
]
62
}
63
}
64
}
65
};
66
67
export function updateContributedOpeners(enumValues: string[], enumDescriptions: string[]): void {
68
externalUriOpenerIdSchemaAddition.enum = enumValues;
69
externalUriOpenerIdSchemaAddition.enumDescriptions = enumDescriptions;
70
71
Registry.as<IConfigurationRegistry>(Extensions.Configuration)
72
.notifyConfigurationSchemaUpdated(externalUriOpenersConfigurationNode);
73
}
74
75