-
Notifications
You must be signed in to change notification settings - Fork 5.9k
Slashes in folder param become escaped #1351
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
Comments
yes i know the name of the issue is horrible, my words have been failing me today |
Fixed :) Thanks for reporting, I confirmed this. |
Yeah, also whats with the I dont understand why it does this? |
Not sure either. cc @code-asher. |
I'm not certain, that just seems to be what VS Code 1.41.1 is doing now. |
To clarify, if you click file > open that's what VS Code puts in the URL, so I updated our server code to match. |
i think it may be because of the implementation? |
Internally VS Code refers to remote files with the vscode-remote:// scheme. In our case the remote provider is code-server but that doesn't change the scheme that VS Code uses. We could change it (and we used to) but there didn't seem any benefit in the added patching it required. |
Ah, alright then, |
Aren't slashes supposed to be URL encoded in query strings? |
It's optional. package main
import (
"fmt"
"net/url"
)
func main() {
u, _ := url.Parse("localhost:8080/?meow=bar/foo&big=coadler/asher")
fmt.Println(u.Query())
} Prints:
|
That's true it parses, but there'd be no way to construct the same thing on the way out package main
import (
"fmt"
"net/url"
)
func main() {
u, err := url.ParseQuery("meow=bar/foo&big=coadler/asher")
if err != nil {
panic(err)
}
fmt.Println(u)
fmt.Println(u.Encode())
}
https://tools.ietf.org/html/rfc2396#section-3.4 seems to indicate slashes are reserved within query strings The documentation for |
That's interesting. So then everything is working as expected. @code-asher Why does the folder argument need the scheme when it's always vscode-remote? Let's just remove it and add it ourselves when appropriate? |
My assumption was that it would eventually be possible (if not already)
to open different schemes on startup. For example maybe a git:// URL or
an ssh:// URL or something.
But that's just a guess and I haven't looked into the commits or issues
to try determining VS Code's reasons for making this change.
|
When using a query parameter without a scheme, the scheme defaults to `file`. This results in the files in the explorer being technically different from the file picker files because they are file:// instead of vscode-remote://, causing the same file to open twice and causing numerous issues. Normally the file explorer wouldn't even load at all in this case but we provide a file service for file:// URLs as a failsafe for certain files that wouldn't load correctly in the past. These files load fine now using the vscode-remote scheme, so I'm also removing that service. Related: #1351. Fixes #1294.
I navigate many times by manually editing the url to open the folder I want. It also helps me easily see the directory that I am currently in, since many times I will have 5 tabs open with different directories. The new vscode-remote:// URL has been pretty annoying. I wish there were a way to keep the folder= URL or at least an option or parameter we can pass when launching code-server. Workaround to give you the old url functionality back: This:
|
Yeah, I find the new format fairly annoying as well. I'm thinking we
should patch VS Code to use the old URL format when the scheme is
vscode-remote. That would restore the old behavior while still allowing
other schemes to be used.
|
how easy would that patch be? |
I imagine it would be a single line change (or two if we want to do the
same for workspace paths). The URL is created in
`src/vs/code/browser/workbench/workbench.ts` in `createTargetUrl` so
we'd just need to make it use `.path` instead of `.toString()` and remove
the encoding.
|
Oh but we'd only do that if the scheme is vscode-remote, otherwise we
keep the current behavior.
|
That sounds great! |
30 lines later...
Thanks Asher! 👏 |
I think we're going to need to revert this (at least re-introduce the encoding) because otherwise you can't open directories with |
Hmm maybe we can decode just the slashes after encoding ( |
@code-asher and can't open paths with spaces which is fairly common. See #1488 |
Description
When changing directories, it becomes
https://code.example.com/?folder=vscode-remote%3A%2F%2Fcode.example.com%2Fhome%2Fdeveloper%2FWorkspace%2FDND
instead of `https://code.example.com/?folder=/home/developer/Workspace/
Steps to Reproduce
https://example.com/
)The text was updated successfully, but these errors were encountered: