You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
changed the title [-]Url changes to non-standard output when changing directories[/-][+]Slases in folder param become escaped for no reason[/+]on Feb 11, 2020
i think it may be because of the implementation?
This suggests that code-server uses a varient of the vscode-remote extension and wasnt properly modifed
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.
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.
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:
My code-server instance sits behind a nginx reverse proxy with Let's Encrypt SSL and a secure username+pwd login form. If anyone has their instance behind an nginx reverse proxy, you can add the configuration lines below to your nginx configs which will strip out the vscode-remote:// and replace the characters with slashes which will give you the url format that we are all used to. Each additional line will support 1 subdirectory deep, so my configs below will support 12 subfolders deep. There may be a better way of doing this but I am new to nginx and only have about 10 hours of experience with it, 2 of which were spent trying to solve this.
set $args_original $args;
if ($args ~ ^(folder=)vscode-remote%3A%2F%2F.*?%2F(.*)$) { set $args $1/$2; }
if ($args ~ ^(folder=.*)%2F(.*)$) { set $args $1/$2; }
if ($args ~ ^(folder=.*)%2F(.*)$) { set $args $1/$2; }
if ($args ~ ^(folder=.*)%2F(.*)$) { set $args $1/$2; }
if ($args ~ ^(folder=.*)%2F(.*)$) { set $args $1/$2; }
if ($args ~ ^(folder=.*)%2F(.*)$) { set $args $1/$2; }
if ($args ~ ^(folder=.*)%2F(.*)$) { set $args $1/$2; }
if ($args ~ ^(folder=.*)%2F(.*)$) { set $args $1/$2; }
if ($args ~ ^(folder=.*)%2F(.*)$) { set $args $1/$2; }
if ($args ~ ^(folder=.*)%2F(.*)$) { set $args $1/$2; }
if ($args ~ ^(folder=.*)%2F(.*)$) { set $args $1/$2; }
if ($args ~ ^(folder=.*)%2F(.*)$) { set $args $1/$2; }
if ($args ~ ^(folder=.*)%2F(.*)$) { set $args $1/$2; }
if ($args != $args_original) {
return 301 "$scheme://${http_host}$uri?$args";
}
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.
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.
I think we're going to need to revert this (at least re-introduce the encoding) because otherwise you can't open directories with #, &, etc to name a few.
Hmm maybe we can decode just the slashes after encoding (.replace("%2F", "/")). Seems to work but I'm not sure if there's some case I'm not considering.
Activity
Merith-TK commentedon Feb 10, 2020
yes i know the name of the issue is horrible, my words have been failing me today
[-]Url changes to non-standard output when changing directories[/-][+]Slases in folder param become escaped for no reason[/+]nhooyr commentedon Feb 11, 2020
Fixed :)
Thanks for reporting, I confirmed this.
[-]Slases in folder param become escaped for no reason[/-][+]Slashes in folder param become escaped[/+]Merith-TK commentedon Feb 11, 2020
Yeah, also whats with the
?folder=vscode-remote%3A%2F%2Fcode.example.com%2Finstead of?folder=/I dont understand why it does this?
nhooyr commentedon Feb 11, 2020
Not sure either. cc @code-asher.
code-asher commentedon Feb 11, 2020
I'm not certain, that just seems to be what VS Code 1.41.1 is doing now.
code-asher commentedon Feb 11, 2020
To clarify, if you click file > open that's what VS Code puts in the URL, so I updated our server code to match.
Merith-TK commentedon Feb 11, 2020
i think it may be because of the implementation?
This suggests that code-server uses a varient of the vscode-remote extension and wasnt properly modifed
code-asher commentedon Feb 11, 2020
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.
Merith-TK commentedon Feb 11, 2020
Ah, alright then,
coadler commentedon Feb 11, 2020
Aren't slashes supposed to be URL encoded in query strings?
nhooyr commentedon Feb 11, 2020
It's optional.
Prints:
coadler commentedon Feb 11, 2020
That's true it parses, but there'd be no way to construct the same thing on the way out
https://tools.ietf.org/html/rfc2396#section-3.4 seems to indicate slashes are reserved within query strings
The documentation for
ParseQuerysays that it expects a URL-encoded query string but seems to work fine if it doesn'thttps://golang.org/src/net/url/url.go?s=25201:25246#L859
nhooyr commentedon Feb 11, 2020
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?
code-asher commentedon Feb 12, 2020
Fix duplicate files opening with folder parameter
JtMotoX commentedon Mar 10, 2020
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:
My code-server instance sits behind a nginx reverse proxy with Let's Encrypt SSL and a secure username+pwd login form. If anyone has their instance behind an nginx reverse proxy, you can add the configuration lines below to your nginx configs which will strip out the vscode-remote:// and replace the characters with slashes which will give you the url format that we are all used to. Each additional line will support 1 subdirectory deep, so my configs below will support 12 subfolders deep. There may be a better way of doing this but I am new to nginx and only have about 10 hours of experience with it, 2 of which were spent trying to solve this.
This:
https://my.domain.com/?folder=vscode-remote%3A%2F%2Fmyhostname%2FUsers%2Fusername%2Ffolder1%2Ffolder2%2Ffolder3
Becomes This:
https://my.domain.com/?folder=/Users/username/folder1/folder2/folder3
code-asher commentedon Mar 10, 2020
Merith-TK commentedon Mar 10, 2020
how easy would that patch be?
code-asher commentedon Mar 11, 2020
code-asher commentedon Mar 11, 2020
JtMotoX commentedon Mar 11, 2020
That sounds great!
JtMotoX commentedon Mar 11, 2020
30 lines later...
Thanks Asher! 👏
code-asher commentedon Mar 16, 2020
I think we're going to need to revert this (at least re-introduce the encoding) because otherwise you can't open directories with
#,&, etc to name a few.code-asher commentedon Mar 16, 2020
Hmm maybe we can decode just the slashes after encoding (
.replace("%2F", "/")). Seems to work but I'm not sure if there's some case I'm not considering.t-d-d commentedon Apr 6, 2020
@code-asher and can't open paths with spaces which is fairly common. See #1488