@@ -20,7 +20,11 @@ export class RemoteAuthorityResolverService extends Disposable implements IRemot
20
20
private readonly _connectionToken : string | undefined ;
21
21
private readonly _connectionTokens : Map < string , string > ;
22
22
23
- constructor ( connectionToken : string | undefined , resourceUriProvider : ( ( uri : URI ) => URI ) | undefined ) {
23
+ /**
24
+ * Add proxy endpoint template.
25
+ * @author coder
26
+ */
27
+ constructor ( connectionToken : string | undefined , resourceUriProvider : ( ( uri : URI ) => URI ) | undefined , private readonly proxyEndpointUrlTemplate ?: string ) {
24
28
super ( ) ;
25
29
this . _cache = new Map < string , ResolverResult > ( ) ;
26
30
this . _connectionToken = connectionToken ;
@@ -59,12 +63,21 @@ export class RemoteAuthorityResolverService extends Disposable implements IRemot
59
63
60
64
private _doResolveAuthority ( authority : string ) : ResolverResult {
61
65
const connectionToken = this . _connectionTokens . get ( authority ) || this . _connectionToken ;
66
+ /**
67
+ * Add VSCODE_PROXY_URI to the environment.
68
+ * @author coder
69
+ */
70
+ const options = { }
71
+ if ( this . proxyEndpointUrlTemplate ) {
72
+ const proxyUrl = new URL ( this . proxyEndpointUrlTemplate , window . location . href ) ;
73
+ options . extensionHostEnv = { VSCODE_PROXY_URI : decodeURIComponent ( proxyUrl . toString ( ) ) }
74
+ }
62
75
if ( authority . indexOf ( ':' ) >= 0 ) {
63
76
const pieces = authority . split ( ':' ) ;
64
- return { authority : { authority, host : pieces [ 0 ] , port : parseInt ( pieces [ 1 ] , 10 ) , connectionToken } } ;
77
+ return { authority : { authority, host : pieces [ 0 ] , port : parseInt ( pieces [ 1 ] , 10 ) , connectionToken } , options } ;
65
78
}
66
79
const port = ( / ^ h t t p s : / . test ( window . location . href ) ? 443 : 80 ) ;
67
- return { authority : { authority, host : authority , port : port , connectionToken } } ;
80
+ return { authority : { authority, host : authority , port : port , connectionToken } , options } ;
68
81
}
69
82
70
83
_clearResolvedAuthority ( authority : string ) : void {
0 commit comments