Skip to content

vscode.open command can't open HTTP URL with hash (#) in it [extension development] #140907

@viktomas-gitlab

Description

@viktomas-gitlab

Does this issue occur when all extensions are disabled?: Yes/No

Version: 1.64.0-insider
Commit: 7ae7f9d
Date: 2022-01-18T05:25:31.041Z (8 hrs ago)
Electron: 13.5.2
Chromium: 91.0.4472.164
Node.js: 14.16.0
V8: 9.1.269.39-electron.0
OS: Darwin arm64 21.2.0

This issue relates to extension development, not the normal use of VS Code.

Steps to Reproduce:

  1. Have a URL with an encoded hash in it (it must be encoded otherwise it would be the start of the Uri fragment)

  2. call

    vscode.commands.executeCommand(
      'vscode.open',
      vscode.Uri.parse('https://gitlab.com/viktomas/test-project/-/tree/test-%23-hash'),
    );
  3. VS Code tries to open https://gitlab.com/viktomas/test-project/-/tree/test-%2523-hash in the browser (it escaped the % character from %23) (I tried to set both Firefox and Safari as the default browser and the issue happens for both)

  4. The same issue happens if the escaped hash is in the query part of the Uri

Running vscode.Uri.parse('https://gitlab.com/viktomas/test-project/-/tree/test-%23-hash').toString() returns https://gitlab.com/viktomas/test-project/-/tree/test-%23-hash which is correct so there must be some additional double-escaping in the VS Code opener.


From the normal user perspective:

When the hash-encoded URL is somewhere in the text editor and you command-click on it, it works well

Kapture.2022-01-18.at.15.08.15.mp4

Metadata

Metadata

Assignees

Labels

bugIssue identified by VS Code Team member as probable buguri

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions