mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-01-28 01:25:39 -05:00
* Revert "Revert "Merge from vscode merge-base (#22769)" (#22779)"
This reverts commit 47a1745180.
* Fix notebook download task
* Remove done call from extensions-ci
42 lines
1.4 KiB
TypeScript
42 lines
1.4 KiB
TypeScript
/*---------------------------------------------------------------------------------------------
|
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
|
*--------------------------------------------------------------------------------------------*/
|
|
import { env, UIKind, Uri } from 'vscode';
|
|
|
|
export function toBase64UrlEncoding(base64string: string) {
|
|
return base64string.replace(/=/g, '').replace(/\+/g, '-').replace(/\//g, '_'); // Need to use base64url encoding
|
|
}
|
|
|
|
const LOCALHOST_ADDRESSES = ['localhost', '127.0.0.1', '0:0:0:0:0:0:0:1', '::1'];
|
|
function isLocalhost(uri: Uri): boolean {
|
|
if (!/^https?$/i.test(uri.scheme)) {
|
|
return false;
|
|
}
|
|
const host = uri.authority.split(':')[0];
|
|
return LOCALHOST_ADDRESSES.indexOf(host) >= 0;
|
|
}
|
|
|
|
export function isSupportedEnvironment(uri: Uri): boolean {
|
|
if (env.uiKind === UIKind.Desktop) {
|
|
return true;
|
|
}
|
|
// local development (localhost:* or 127.0.0.1:*)
|
|
if (isLocalhost(uri)) {
|
|
return true;
|
|
}
|
|
// At this point we should only ever see https
|
|
if (uri.scheme !== 'https') {
|
|
return false;
|
|
}
|
|
|
|
return (
|
|
// vscode.dev & insiders.vscode.dev
|
|
/(?:^|\.)vscode\.dev$/.test(uri.authority) ||
|
|
// github.dev & codespaces
|
|
/(?:^|\.)github\.dev$/.test(uri.authority) ||
|
|
// github.dev/codespaces local setup (github.localhost)
|
|
/(?:^|\.)github\.localhost$/.test(uri.authority)
|
|
);
|
|
}
|