Share common util code with VS Code
This lets us re-use the normalized base path so when we expire/clear the cookie we use the same base path.
This commit is contained in:
@ -13,10 +13,18 @@ import { Registry } from 'vs/platform/registry/common/platform';
|
||||
import { IStorageService, StorageScope, StorageTarget } from 'vs/platform/storage/common/storage';
|
||||
import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry';
|
||||
import { TelemetryChannelClient } from 'vs/server/common/telemetry';
|
||||
import { getOptions } from 'vs/server/common/util';
|
||||
import 'vs/workbench/contrib/localizations/browser/localizations.contribution';
|
||||
import 'vs/workbench/services/localizations/browser/localizationsService';
|
||||
import { IRemoteAgentService } from 'vs/workbench/services/remote/common/remoteAgentService';
|
||||
|
||||
/**
|
||||
* All client-side customization to VS Code should live in this file when
|
||||
* possible.
|
||||
*/
|
||||
|
||||
const options = getOptions<Options>();
|
||||
|
||||
class TelemetryService extends TelemetryChannelClient {
|
||||
public constructor(
|
||||
@IRemoteAgentService remoteAgentService: IRemoteAgentService,
|
||||
@ -25,26 +33,6 @@ class TelemetryService extends TelemetryChannelClient {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove extra slashes in a URL.
|
||||
*/
|
||||
export const normalize = (url: string, keepTrailing = false): string => {
|
||||
return url.replace(/\/\/+/g, '/').replace(/\/+$/, keepTrailing ? '/' : '');
|
||||
};
|
||||
|
||||
/**
|
||||
* Get options embedded in the HTML.
|
||||
*/
|
||||
export const getOptions = <T extends Options>(): T => {
|
||||
try {
|
||||
return JSON.parse(document.getElementById('coder-options')!.getAttribute('data-settings')!);
|
||||
} catch (error) {
|
||||
return {} as T;
|
||||
}
|
||||
};
|
||||
|
||||
const options = getOptions();
|
||||
|
||||
const TELEMETRY_SECTION_ID = 'telemetry';
|
||||
Registry.as<IConfigurationRegistry>(Extensions.Configuration).registerConfiguration({
|
||||
'id': TELEMETRY_SECTION_ID,
|
||||
|
1
lib/vscode/src/vs/server/common/util.ts
Symbolic link
1
lib/vscode/src/vs/server/common/util.ts
Symbolic link
@ -0,0 +1 @@
|
||||
../../../../../../src/common/util.ts
|
Reference in New Issue
Block a user