Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Monaco uri parse wrongly parses URL #1097

Closed
mkapiczy opened this issue Oct 9, 2018 · 3 comments
Closed

Monaco uri parse wrongly parses URL #1097

mkapiczy opened this issue Oct 9, 2018 · 3 comments
Assignees

Comments

@mkapiczy
Copy link

mkapiczy commented Oct 9, 2018

monaco.Uri.parse wrongly parses URL if it contains the fragment part in the beginning of the path.

This is my url:
http://localhost:8081/#/applications/app/82bb8afa-0401-4562-aca2-2eb1ff2eb06a/field/fe5ba7a9-689d-4cc2-89ae-fc076c6473cc

The parse method turns it into:

http://localhost:8081/#/%2Fapplications%2Fapp%2F82bb8afa-0401-4562-aca2-2eb1ff2eb06a%2Ffield%2Ffe5ba7a9-689d-4cc2-89ae-fc076c6473cc

When I remove the # sign it works, but that is a valid URL, so I would expect it to be handled by the parser.

@mkapiczy mkapiczy changed the title Monaco uri parse turns '/' character to %2F Monaco uri parse wrongly parses URL Oct 9, 2018
@schirrel
Copy link

itllooks like the / is being escaped

@jrieken
Copy link
Member

jrieken commented Nov 12, 2018

It's not about parse but toString. Invoke it with true for minimal encoding

@mkapiczy
Copy link
Author

mkapiczy commented Mar 14, 2019

Sorry for reopening it again but I solved it previously another way (using a vue router instead of monaco redirection) and now I encounter the issue once again.

So I register a custom definition provider:

monaco.languages.registerDefinitionProvider('javascript', {
        provideDefinition: (model, position, cancellationToken) => {
          /**
          * Get the uri to redirect to
           */
          const uri = getTheUriSomehowInStringFormat()
              return {
                uri: monaco.Uri.parse(uri),
                range: new monaco.Range(3, 1, 3, 1)
              }
            })
    }

And now I am redirected to the uri with escaped / character. If that's just a toString method then I guess it's monaco internal call of toString somewhere?

@vscodebot vscodebot bot locked and limited conversation to collaborators Oct 29, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants