Skip to content

Test: Protocol handler API #48427

@joaomoreno

Description

@joaomoreno

Test for #46256:

Complexity: 3

Authors: @joaomoreno


Setup

First, make sure your extension sets "enableProposedApi": true in its manifest. Then, get the latest definitions:

  1. Change the engine.vscode property to * in package.json
  2. Run npm run postinstall
  3. Undo step 1

URI Format

Uris directed towards extension vscode.git, for example, all share the following prefix:

{scheme}://vscode.git

(with vscode.git being the extension id).

For example, for VS Code Insiders, these are valid Uris which will be handled by the git extension's protocol handler:

vscode-insiders://vscode.git
vscode-insiders://vscode.git/
vscode-insiders://vscode.git/status
vscode-insiders://vscode.git/clone?url=foobar

Test Details

As an extension author, you can:

  • Use the new ProtocolHandler proposed API, to handle such Uris
  • Use a new activation event onUri to be activated when a Uri for that extension is opened. This should work in all cases:
    • A Code window is open
    • No Code windows are open, but Code is running (macOS)
    • Code is not running at all
  • As a user, you should be prompted to confirm opening Urls directed to extensions

Here's how you can test Uri opening:

  • Windows: type explorer URI in a command prompt
  • macOS: type open URI in a shell
  • Linux: type xdg-open URI in a shell

You can also open a URL from the command line with --open-url URL. This can be used simultaneously with --enable-proposed-api.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions