Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
microsoft
GitHub Repository: microsoft/vscode
Path: blob/main/src/vs/workbench/api/node/uriTransformer.ts
3296 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 { UriParts, IRawURITransformer, URITransformer, IURITransformer } from '../../../base/common/uriIpc.js';
7
8
/**
9
* ```
10
* --------------------------------
11
* | UI SIDE | AGENT SIDE |
12
* |---------------|--------------|
13
* | vscode-remote | file |
14
* | file | vscode-local |
15
* --------------------------------
16
* ```
17
*/
18
function createRawURITransformer(remoteAuthority: string): IRawURITransformer {
19
return {
20
transformIncoming: (uri: UriParts): UriParts => {
21
if (uri.scheme === 'vscode-remote') {
22
return { scheme: 'file', path: uri.path, query: uri.query, fragment: uri.fragment };
23
}
24
if (uri.scheme === 'file') {
25
return { scheme: 'vscode-local', path: uri.path, query: uri.query, fragment: uri.fragment };
26
}
27
return uri;
28
},
29
transformOutgoing: (uri: UriParts): UriParts => {
30
if (uri.scheme === 'file') {
31
return { scheme: 'vscode-remote', authority: remoteAuthority, path: uri.path, query: uri.query, fragment: uri.fragment };
32
}
33
if (uri.scheme === 'vscode-local') {
34
return { scheme: 'file', path: uri.path, query: uri.query, fragment: uri.fragment };
35
}
36
return uri;
37
},
38
transformOutgoingScheme: (scheme: string): string => {
39
if (scheme === 'file') {
40
return 'vscode-remote';
41
} else if (scheme === 'vscode-local') {
42
return 'file';
43
}
44
return scheme;
45
}
46
};
47
}
48
49
export function createURITransformer(remoteAuthority: string): IURITransformer {
50
return new URITransformer(createRawURITransformer(remoteAuthority));
51
}
52
53