fix: allow hash character in paths #5122
Merged
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.
Allow hash character in paths
Insteadfile:${...}
we need to usepathToFileURL
(fromnode:url
) because some paths can contain hash character (#
) or other characters (I guess, question mark (?
) could also be a problem) that are cut off when the URI (file:
schema) points file to be accessed by file system.The
file:${...}
instances would need replacing hash character (#
) with its URI encoded value (%23
) to prevent it being reparsed along the way. My previous idea of usingpathToFileURL
wouldn't work, as relative paths got pre-resolved before converting to URL, i.e.file:../hello
with CWD ofS:\\test\\directory
would becamefile://S:\\test\\hello
while some instances of code (NPA) expected not unresolvedfile:..\\hello
. Aside of that, simply replacing the char would be faster. By the way, I am almost certain that the hash character is the only "weird" character that could be used in the paths, as question mark (despite being beginning of query params) hardly can't nor should be used for names (Windows disallows).References
Fixes #5120
Pending work
file:
was used and if similar patch could be applied.