Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
microsoft
GitHub Repository: microsoft/vscode
Path: blob/main/extensions/microsoft-authentication/src/common/uri.ts
3320 views
1
/*---------------------------------------------------------------------------------------------
2
* Copyright (c) Microsoft Corporation. All rights reserved.
3
* Licensed under the MIT License. See License.txt in the project root for license information.
4
*--------------------------------------------------------------------------------------------*/
5
import { env, UIKind, Uri } from 'vscode';
6
7
const LOCALHOST_ADDRESSES = ['localhost', '127.0.0.1', '0:0:0:0:0:0:0:1', '::1'];
8
function isLocalhost(uri: Uri): boolean {
9
if (!/^https?$/i.test(uri.scheme)) {
10
return false;
11
}
12
const host = uri.authority.split(':')[0];
13
return LOCALHOST_ADDRESSES.indexOf(host) >= 0;
14
}
15
16
export function isSupportedEnvironment(uri: Uri): boolean {
17
if (env.uiKind === UIKind.Desktop) {
18
return true;
19
}
20
// local development (localhost:* or 127.0.0.1:*)
21
if (isLocalhost(uri)) {
22
return true;
23
}
24
// At this point we should only ever see https
25
if (uri.scheme !== 'https') {
26
return false;
27
}
28
29
return (
30
// vscode.dev & insiders.vscode.dev
31
/(?:^|\.)vscode\.dev$/.test(uri.authority) ||
32
// github.dev & codespaces
33
/(?:^|\.)github\.dev$/.test(uri.authority) ||
34
// github.dev/codespaces local setup (github.localhost)
35
/(?:^|\.)github\.localhost$/.test(uri.authority)
36
);
37
}
38
39