Skip to content

In some places, allow to use URL in addition to URI #85930

Open

Description

This is followup work from #83645 and in essence it's about allowing to use the URL-type when dealing with resources outside of VS Code. So far we have identified:

  • the openExternal-api
  • the DocumentLinkProvider-api

Activity

  1. tjx666 commented on Jan 18, 2020

    @tjx666
    Contributor

    is there any progress? Johannes Rieken (@jrieken)

  2. nblagoev commented on Apr 10, 2020

    @nblagoev

    Hi Johannes Rieken (@jrieken), any ETA on resolving this? I cannot find a way out of this encoding problem with vscode.env.openExternal

    • Tried the same URL from the verification steps described at URI vs URL and going forward #83645 (comment)

      vscode.env.openExternal(
          vscode.Uri.parse(
              "https://firebasestorage.googleapis.com/v0/b/brewlangerie.appspot.com/o/products%2FzVNZkudXJyq8bPGTXUxx%2FBetterave-Sesame.jpg?alt=media&token=0b2310c4-3ea6-4207-bbde-9c3710ba0437"
          )
      )
    • Browser opens (1) with 400 Invalid HTTP method/URL pair. instead of (2)

      (1) https://firebasestorage.googleapis.com/v0/b/brewlangerie.appspot.com/o/products/zVNZkudXJyq8bPGTXUxx/Betterave-Sesame.jpg?alt=media&token=0b2310c4-3ea6-4207-bbde-9c3710ba0437
      
      (2) https://firebasestorage.googleapis.com/v0/b/brewlangerie.appspot.com/o/products%2FzVNZkudXJyq8bPGTXUxx%2FBetterave-Sesame.jpg?alt=media&token=0b2310c4-3ea6-4207-bbde-9c3710ba0437
      
  3. added
    feature-request
    on Apr 14, 2020
  4. DanTup commented on May 20, 2020

    @DanTup
    Contributor

    I'm blocked on this now too - I need to open URLs that have fragments and they get encoded incorrectly.

    Johannes Rieken (@jrieken) this isn't assigned to any milestone - do you think it's likely to happen in the near future? Would you accept a PR that just adds an overload that takes URL in openExternal?

    We can work around it for non-remote workspaces by just launching the browser ourselves, but it'll still be broken in VS Codespaces and friends.

  5. jrieken commented on May 20, 2020

    @jrieken
    ContributorAuthor

    It isn't a trivial change but feel free to give it a try, code pointer:

    let uriAsString: string | undefined;

  6. DanTup commented on May 20, 2020

    @DanTup
    Contributor

    It isn't a trivial change

    Before I bite off more than I can chew, what makes you say that? I thought it might just be a case of accepting a URL all the way through (in the same way as it currently accepts a URI). Now I'm not so sure 😄

    (though probably if it was so simple, it would've been done already! ..)

  7. jrieken commented on May 26, 2020

    @jrieken
    ContributorAuthor

    For remote extension hosts, all uris go through some special handling so that an extension can talk about a (local) file-uri and so that the UI knows that it's a file-uri on the other machine. So, now the question is if URL objects should also go through that mechanism (which requires them to be uris) or not

  8. DanTup commented on May 26, 2020

    @DanTup
    Contributor

    I see - it does sound like there's more to it than I thought.

    I've managed to work around it for now (passing things on the querystring - which isn't affected as much by the encoding - instead of the fragment, and having the receiving app move them over) as I needed a fix for the next release.

  9. chdsbd commented on Apr 17, 2021

    @chdsbd

    As a hack, I was able to pass a string to vscode.env.openExternal(myUrl) instead of using vscode.env.openExternal(vscode.Uri.parse(myUrl)). I don't know how robust this is because I had to @ts-ignore the call, but it works for my use case and my url no longer gets double encoded.

  10. akosyakov commented on Oct 15, 2021

    @akosyakov
    Contributor

    Stumbled on the similar issue while trying to open external with query params for ouath2. ? in redirect URI gets double encoded. It would be nice if just string type can be allowed for external URIs 🙏

  11. DavidGoldman commented on Apr 13, 2022

    @DavidGoldman
    Contributor

    It seems like this could be supported by changing the API to note it supports a string - or maybe introduce another API to avoid this double-encoding issue?

  12. eamodio commented on Jun 1, 2022

    @eamodio
    Contributor

    I got bit by this as well: gitkraken/vscode-gitlens#2014

    As David Goldman (@DavidGoldman) notes, passing a string works and avoids this problem. Johannes Rieken (@jrieken) could the .d.ts be updated to allow a string?

  13. added a commit that references this issue on Jun 1, 2022
  14. DavidGoldman commented on Aug 22, 2022

    @DavidGoldman
  15. tjx666 commented on Dec 24, 2022

    @tjx666
    Contributor

    Johannes Rieken (@jrieken) My issue #88273 is marked as duplicated with this issue, but I think it may not same with this.

    I test following solution, but not work for my situation on windows.

    As a hack, I was able to pass a string to vscode.env.openExternal(myUrl) instead of using vscode.env.openExternal(vscode.Uri.parse(myUrl)). I don't know how robust this is because I had to @ts-ignore the call, but it works for my use case and my url no longer gets double encoded.

  16. brpaz commented on Feb 20, 2023

    @brpaz

    Hello. Any chance this can be fixed? an extension that I am building relies on openExternal to open files with an external protocol, and it´s encoding the "=" in the query string, breaking the url handler.

    Anton Kosyakov (@akosyakov) hack worked for me, in the meanwhile.

  17. max-samusevich commented on Mar 13, 2023

    @max-samusevich

    Hello. Any chance this can be fixed? an extension that I am building relies on openExternal to open files with an external protocol, and it´s encoding the "=" in the query string, breaking the url handler.

    Anton Kosyakov (@akosyakov) hack worked for me, in the meanwhile.

    Same for me. I'm trying to open an external app with a link in an .md file: [test link](obsidian://open?vault=Obsidian%20Sandbox&file=Adventurer%2FNo%20prior%20experience), but I get an error alert if I click the link in the file itself and get no response in a default md preview, same with a preview from the Markdown preview enhanced extension.

    VS Code encodes "=" signs

    A also tried to add the "obsidian://" protocol to accepted protocols for links that are processed by the Markdown preview enhanced extension but still nothing happens in the preview mode of this extension.

  18. Wroud commented on May 8, 2025

    @Wroud

    Same here, link like:

    http://127.0.0.1:8080/auth-complex?redirect_uri=vscode%3A%2F%2Fdbeaver.vscode-extension%2F&state=fd2dc38d86ae012e6419ce8261d7d9d3&code_challenge=KTcIpKVbYtg4J6WkRlqd%2FU57k21nVeizW2BNINhRI5w%3D
    

    Will be incorrectly encoded to:

    http://127.0.0.1:8080/auth-complex?redirect_uri%3Dvscode%3A%2F%2Fdbeaver.vscode-extension%2F%26state%3Dfd2dc38d86ae012e6419ce8261d7d9d3%26code_challenge%3DKTcIpKVbYtg4J6WkRlqd%2FU57k21nVeizW2BNINhRI5w%3D
    

    Code:

    vscode.Uri.parse(authUrl.toString()).toString()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    apifeature-requesturi

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions