mirror of
https://github.com/coder/coder.git
synced 2026-09-24 15:04:27 +08:00
fix(cli): use app slug instead of raw command in terminal URLs (#24827)
This commit is contained in:
+1
-5
@@ -645,7 +645,6 @@ func buildAppLinkURL(baseURL *url.URL, workspace codersdk.Workspace, agent coder
|
||||
agent.Name,
|
||||
url.PathEscape(app.Slug),
|
||||
)
|
||||
// The frontend leaves the returns a relative URL for the terminal, but we don't have that luxury.
|
||||
if app.Command != "" {
|
||||
u.Path = fmt.Sprintf(
|
||||
"%s/@%s/%s.%s/terminal",
|
||||
@@ -655,11 +654,8 @@ func buildAppLinkURL(baseURL *url.URL, workspace codersdk.Workspace, agent coder
|
||||
agent.Name,
|
||||
)
|
||||
q := u.Query()
|
||||
q.Set("command", app.Command)
|
||||
q.Set("app", app.Slug)
|
||||
u.RawQuery = q.Encode()
|
||||
// encodeURIComponent replaces spaces with %20 but url.QueryEscape replaces them with +.
|
||||
// We replace them with %20 to match the TypeScript implementation.
|
||||
u.RawQuery = strings.ReplaceAll(u.RawQuery, "+", "%20")
|
||||
}
|
||||
|
||||
if appsHost != "" && app.Subdomain && app.SubdomainName != "" {
|
||||
|
||||
@@ -114,9 +114,10 @@ func Test_buildAppLinkURL(t *testing.T) {
|
||||
Name: "a-workspace-agent",
|
||||
},
|
||||
app: codersdk.WorkspaceApp{
|
||||
Slug: "my-terminal",
|
||||
Command: "ls -la",
|
||||
},
|
||||
expectedLink: "https://coder.tld/@username/Test-Workspace.a-workspace-agent/terminal?command=ls%20-la",
|
||||
expectedLink: "https://coder.tld/@username/Test-Workspace.a-workspace-agent/terminal?app=my-terminal",
|
||||
},
|
||||
{
|
||||
name: "with subdomain",
|
||||
|
||||
Reference in New Issue
Block a user