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