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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It seems this
encodeURI
was added in facebook/create-react-app#2076 to allow URLs containing"
. I think we should dourl.replaceAll('"', '%22')
here.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for your review! I have carefully checked all the code calling the
openBrowser
method. The URL obtained fromserver.resolvedUrls?.local[0] ?? server.resolvedUrls?.network[0]
and the path retrieved fromnew URL(options.open, url).href
both already encode the"
. Is it still necessary to addurl.replaceAll('"', '%22')
to encode"
in this method?Looking forward to your feedback!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, then it should be ok. Thanks for checking!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There's a spot where we don't use
new URL()
. Maybe we should add it while we're at it:vite/packages/vite/src/node/shortcuts.ts
Lines 142 to 150 in b80daa7
This part is for the preview server, which it's handling it correctly this way, but not for its shortcuts:
vite/packages/vite/src/node/preview.ts
Lines 260 to 268 in b80daa7
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@bluwy Both handles
resolvedUrls
the same way (passesopenBrowser
withoutnew URL()
). Are you suggesting to dourl = new URL(url).href
?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@bluwy Thank you for pointing that out!
I’ve checked the part of the code you mentioned, and the URL obtained from
server.resolvedUrls?.local[0] ?? server.resolvedUrls?.network[0]
is already URL-encoded. So, I think there is no need to usenew URL()
in this case.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You're right I got it mixed up. I was suggesting adding:
It's a different bug now that I look at it. We can do in a separate PR