-
Notifications
You must be signed in to change notification settings - Fork 29.7k
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
Rework Uri.parse and Uri.toString #83060
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
….parse Add tests that check our logic against Nodejs's pathToFileURL
…scape backslash in non-windows cases
928PJY
reviewed
Oct 23, 2019
928PJY
reviewed
Oct 23, 2019
This was referenced Oct 24, 2019
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
tl;dr - This PR is about reimplementing our
Uri.parse
andUri.toString
to be more standard compliant (or closer to what users expect) but without breaking existing code that relies on its quirks.The overall URI situation is unhappy because when VS Code started the "offical" URL global didn't exit yet. Therefore we have our own URI implementation - it serves us as data container for the typical uri components: scheme, authority, path, query, and fragment (see https://tools.ietf.org/html/rfc3986#section-3). To make dealing with UNC path simpler we added
fsPath
to our implementation. Also, our implementation of URI.toString normalises the outcome, e.g. percent encoded sequences are upper-cased, windows drive letters are lower-cased etc, and that allows its result to be used as key in hash maps.The needs of VS Code are fulfilled with the current implementation and generally trouble free. Issues happen when "our" URIs leave VS Code, e.g to a browser to open a link. Then issues with encoding/decoding happen because we encode too much. On top, our implementation decodes on parse (whereas the WHATWG url encodes on parse) and can potentially loose data along the route by not re-encoding things.
Given tight constraints and the high risk of breakage we cannot fix all issues but the following are aimed at
?key=value
, Support URL specific encodings (query component) #25852