Merge from vscode 64980ea1f3f532c82bb6c28d27bba9ef2c5b4463 (#7206)

* Merge from vscode 64980ea1f3f532c82bb6c28d27bba9ef2c5b4463

* fix config changes

* fix strictnull checks
This commit is contained in:
Anthony Dresser
2019-09-15 22:38:26 -07:00
committed by GitHub
parent fa6c52699e
commit ea0f9e6ce9
1226 changed files with 21541 additions and 17633 deletions

View File

@@ -3,7 +3,7 @@
* Licensed under the Source EULA. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import { URI } from 'vs/base/common/uri';
import { URI, UriComponents } from 'vs/base/common/uri';
import * as platform from 'vs/base/common/platform';
export namespace Schemas {
@@ -60,18 +60,24 @@ class RemoteAuthoritiesImpl {
private readonly _ports: { [authority: string]: number; };
private readonly _connectionTokens: { [authority: string]: string; };
private _preferredWebSchema: 'http' | 'https';
private _delegate: ((uri: URI) => UriComponents) | null;
constructor() {
this._hosts = Object.create(null);
this._ports = Object.create(null);
this._connectionTokens = Object.create(null);
this._preferredWebSchema = 'http';
this._delegate = null;
}
public setPreferredWebSchema(schema: 'http' | 'https') {
this._preferredWebSchema = schema;
}
public setDelegate(delegate: (uri: URI) => UriComponents): void {
this._delegate = delegate;
}
public set(authority: string, host: string, port: number): void {
this._hosts[authority] = host;
this._ports[authority] = port;
@@ -81,7 +87,12 @@ class RemoteAuthoritiesImpl {
this._connectionTokens[authority] = connectionToken;
}
public rewrite(authority: string, path: string): URI {
public rewrite(uri: URI): URI {
if (this._delegate) {
const result = this._delegate(uri);
return URI.revive(result);
}
const authority = uri.authority;
const host = this._hosts[authority];
const port = this._ports[authority];
const connectionToken = this._connectionTokens[authority];
@@ -89,7 +100,7 @@ class RemoteAuthoritiesImpl {
scheme: platform.isWeb ? this._preferredWebSchema : Schemas.vscodeRemoteResource,
authority: `${host}:${port}`,
path: `/vscode-remote-resource`,
query: `path=${encodeURIComponent(path)}&tkn=${encodeURIComponent(connectionToken)}`
query: `path=${encodeURIComponent(uri.path)}&tkn=${encodeURIComponent(connectionToken)}`
});
}
}