Skip to content

Commit

Permalink
Add check for isWeb before reading clipboard in (#14593)
Browse files Browse the repository at this point in the history
UserJupyterServerUriInput
  • Loading branch information
DonJayamanne authored Oct 30, 2023
1 parent dc2c785 commit 3917e7b
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/standalone/userJupyterServer/userServerUrlProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ import { JupyterHubPasswordConnect } from '../userJupyterHubServer/jupyterHubPas
import { sendTelemetryEvent } from '../../telemetry';
import { getTelemetrySafeHashedString } from '../../platform/telemetry/helpers';
import { generateIdFromRemoteProvider } from '../../kernels/jupyter/jupyterUtils';
import { isWeb } from '../../platform/vscode-path/platform';

export const UserJupyterServerUriListKey = 'user-jupyter-server-uri-list';
export const UserJupyterServerUriListKeyV2 = 'user-jupyter-server-uri-list-version2';
Expand Down Expand Up @@ -790,10 +791,14 @@ export class UserJupyterServerUriInput {
initialErrorMessage: string = '',
disposables: Disposable[]
): Promise<{ url: string; jupyterServerUri: IJupyterServerUri }> {
if (!initialValue) {
// In the browser, users are prompted to allow access to clipboard, and
// thats not a good UX, because as soon as user clicks kernel picker they get prompted to allow clipbpard access
if (!initialValue && !isWeb) {
try {
const text = await this.clipboard.readText().catch(() => '');
const parsedUri = Uri.parse(text.trim(), true);
const parsedUri = text.trim().startsWith('https://github.com/')
? undefined
: Uri.parse(text.trim(), true);
// Only display http/https uris.
initialValue = text && parsedUri && parsedUri.scheme.toLowerCase().startsWith('http') ? text : '';
} catch {
Expand Down

0 comments on commit 3917e7b

Please sign in to comment.