Skip to content

API: Support protocol handlers #46256

@joaomoreno

Description

@joaomoreno

From #45685

Problem

There is no current way for extension to react on URLs being open with the vscode: scheme. Allowing extensions to do so can enable many different scenarios. A specific one is to provide Clone URLs in Github/TFS which would simply invoke VS Code to clone a URL, using its git extension.

Security Concerns

Allowing extensions to handle a URL doesn't seem to open any additional security concerns, since it's already possible to run arbitrary code by having a user click a URL while taking advantage of the * activation event.

There is no added API for this to happen, since we can leverage commands to handle URLs and the contributes manifest field to expose a URL handler.

An example URL format would be:

vscode://pub.name/...

Proposal

I suggest to keep it simple and allow a single URL handler per extension:

  "contributes": {
    "urlHandler": "handleURLCommand"
  }
}

The handleURLCommand would be invoked with a single instance of vscode.Uri as a single argument:

commands.registerCommand('handleURLCommand', (uri: vscode.Uri) => { /* ... */ });

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions