use URL class in a few places

This commit is contained in:
Tyler Leonhardt 2022-03-29 16:19:58 -07:00
parent edcfff3d4f
commit 62866e4fa5
No known key found for this signature in database
GPG key ID: 1BC2B6244363E77E
2 changed files with 12 additions and 5 deletions

View file

@ -10,13 +10,17 @@ const VALID_DESKTOP_CALLBACK_SCHEMES = [
// On Windows, some browsers don't seem to redirect back to OSS properly.
// As a result, you get stuck in the auth flow. We exclude this from the
// list until we can figure out a way to fix this behavior in browsers.
// The behavior was experienced on Windows.
// 'code-oss',
'vscode-wsl',
'vscode-exploration'
];
// This comes from the GitHub Authentication server
export function isSupportedEnvironment(url: Uri): boolean {
return VALID_DESKTOP_CALLBACK_SCHEMES.includes(url.scheme) || url.authority.endsWith('vscode.dev') || url.authority.endsWith('github.dev');
export function isSupportedEnvironment(uri: Uri): boolean {
return (
VALID_DESKTOP_CALLBACK_SCHEMES.includes(uri.scheme) ||
// vscode.dev & insiders.vscode.dev
/(?:^|\.)vscode\.dev$/.test(uri.authority) ||
// github.dev & codespaces
/(?:^|\.)github\.dev$/.test(uri.authority)
);
}

View file

@ -167,7 +167,10 @@ export class GitHubServer implements IGitHubServer {
const proxyEndpoints: { [providerId: string]: string } | undefined = await vscode.commands.executeCommand('workbench.getCodeExchangeProxyEndpoints');
// If we are running in insiders vscode.dev, then ensure we use the redirect route on that.
const redirectUri = proxyEndpoints?.github?.includes('https://insiders.vscode.dev') ? REDIRECT_URL_INSIDERS : REDIRECT_URL_STABLE;
let redirectUri = REDIRECT_URL_STABLE;
if (proxyEndpoints?.github && new URL(proxyEndpoints.github).hostname === 'insiders.vscode.dev') {
redirectUri = REDIRECT_URL_INSIDERS;
}
const searchParams = new URLSearchParams([
['client_id', CLIENT_ID],
['redirect_uri', redirectUri],