mirror of
https://github.com/microsoft/vscode.git
synced 2026-02-21 10:17:25 +00:00
Add client version information to /web-extension-resource/ (#149370)
This commit is contained in:
@@ -98,6 +98,7 @@ export class WebClientServer {
|
||||
|
||||
private readonly _staticRoute: string;
|
||||
private readonly _callbackRoute: string;
|
||||
private readonly _webExtensionRoute: string;
|
||||
|
||||
constructor(
|
||||
private readonly _connectionToken: ServerConnectionToken,
|
||||
@@ -110,6 +111,7 @@ export class WebClientServer {
|
||||
const serverRootPath = getRemoteServerRootPath(_productService);
|
||||
this._staticRoute = `${serverRootPath}/static`;
|
||||
this._callbackRoute = `${serverRootPath}/callback`;
|
||||
this._webExtensionRoute = `${serverRootPath}/web-extension-resource`;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -131,7 +133,7 @@ export class WebClientServer {
|
||||
// callback support
|
||||
return this._handleCallback(res);
|
||||
}
|
||||
if (/^\/web-extension-resource\//.test(pathname)) {
|
||||
if (pathname.startsWith(this._webExtensionRoute) && pathname.charCodeAt(this._webExtensionRoute.length) === CharCode.Slash) {
|
||||
// extension resource support
|
||||
return this._handleWebExtensionResource(req, res, parsedUrl);
|
||||
}
|
||||
@@ -177,7 +179,7 @@ export class WebClientServer {
|
||||
|
||||
// Strip `/web-extension-resource/` from the path
|
||||
const normalizedPathname = decodeURIComponent(parsedUrl.pathname!); // support paths that are uri-encoded (e.g. spaces => %20)
|
||||
const path = normalize(normalizedPathname.substr('/web-extension-resource/'.length));
|
||||
const path = normalize(normalizedPathname.substring(this._webExtensionRoute.length + 1));
|
||||
const uri = URI.parse(path).with({
|
||||
scheme: this._webExtensionResourceUrlTemplate.scheme,
|
||||
authority: path.substring(0, path.indexOf('/')),
|
||||
@@ -311,7 +313,7 @@ export class WebClientServer {
|
||||
'resourceUrlTemplate': this._webExtensionResourceUrlTemplate.with({
|
||||
scheme: 'http',
|
||||
authority: remoteAuthority,
|
||||
path: `web-extension-resource/${this._webExtensionResourceUrlTemplate.authority}${this._webExtensionResourceUrlTemplate.path}`
|
||||
path: `${this._webExtensionRoute}/${this._webExtensionResourceUrlTemplate.authority}${this._webExtensionResourceUrlTemplate.path}`
|
||||
}).toString(true)
|
||||
} : undefined
|
||||
},
|
||||
|
||||
@@ -17,6 +17,7 @@ import { IStorageService } from 'vs/platform/storage/common/storage';
|
||||
import { TelemetryLevel } from 'vs/platform/telemetry/common/telemetry';
|
||||
import { getTelemetryLevel, supportsTelemetry } from 'vs/platform/telemetry/common/telemetryUtils';
|
||||
import { RemoteAuthorities } from 'vs/base/common/network';
|
||||
import { getRemoteServerRootPath } from 'vs/platform/remote/common/remoteHosts';
|
||||
|
||||
export const WEB_EXTENSION_RESOURCE_END_POINT = 'web-extension-resource';
|
||||
|
||||
@@ -49,6 +50,7 @@ export abstract class AbstractExtensionResourceLoaderService implements IExtensi
|
||||
|
||||
readonly _serviceBrand: undefined;
|
||||
|
||||
private readonly _webExtensionResourceEndPoint: string;
|
||||
private readonly _extensionGalleryResourceUrlTemplate: string | undefined;
|
||||
private readonly _extensionGalleryAuthority: string | undefined;
|
||||
|
||||
@@ -59,6 +61,7 @@ export abstract class AbstractExtensionResourceLoaderService implements IExtensi
|
||||
private readonly _environmentService: IEnvironmentService,
|
||||
private readonly _configurationService: IConfigurationService,
|
||||
) {
|
||||
this._webExtensionResourceEndPoint = `${getRemoteServerRootPath(_productService)}/${WEB_EXTENSION_RESOURCE_END_POINT}/`;
|
||||
if (_productService.extensionsGallery) {
|
||||
this._extensionGalleryResourceUrlTemplate = _productService.extensionsGallery.resourceUrlTemplate;
|
||||
this._extensionGalleryAuthority = this._extensionGalleryResourceUrlTemplate ? this._getExtensionGalleryAuthority(URI.parse(this._extensionGalleryResourceUrlTemplate)) : undefined;
|
||||
@@ -115,7 +118,7 @@ export abstract class AbstractExtensionResourceLoaderService implements IExtensi
|
||||
}
|
||||
|
||||
protected _isWebExtensionResourceEndPoint(uri: URI): boolean {
|
||||
return uri.path.startsWith(`/${WEB_EXTENSION_RESOURCE_END_POINT}/`);
|
||||
return uri.path.startsWith(this._webExtensionResourceEndPoint);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user