-
Notifications
You must be signed in to change notification settings - Fork 5.9k
/
Copy pathuri_transformer.ts
44 lines (37 loc) · 1.28 KB
/
uri_transformer.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
// NOTE: copied over from lib/vscode/src/vs/common/uriIpc.ts
// remember to update this for proper type checks!
interface UriParts {
scheme: string;
authority?: string;
path?: string;
}
interface IRawURITransformer {
transformIncoming(uri: UriParts): UriParts;
transformOutgoing(uri: UriParts): UriParts;
transformOutgoingScheme(scheme: string): string;
}
// This is deliberate! see src/vs/workbench/services/extensions/node/extensionHostProcessSetup.ts
export = function rawURITransformerFactory(authority: string) {
return new RawURITransformer(authority);
}
class RawURITransformer implements IRawURITransformer {
constructor(private readonly authority: string) {}
transformIncoming(uri: UriParts): UriParts {
switch (uri.scheme) {
case "vscode-remote": return {scheme: "file", path: uri.path};
default: return uri;
}
}
transformOutgoing(uri: UriParts): UriParts {
switch (uri.scheme) {
case "file": return {scheme: "vscode-remote", authority: this.authority, path: uri.path};
default: return uri;
}
}
transformOutgoingScheme(scheme: string): string {
switch (scheme) {
case "file": return "vscode-remote";
default: return scheme;
}
}
}