Skip to content

Commit a9c112b

Browse files
committed
fix: handle extra workspace name case
1 parent e6facaa commit a9c112b

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

cli/ssh.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1453,6 +1453,7 @@ func collectNetworkStats(ctx context.Context, agentConn *workspacesdk.AgentConn,
14531453
// Converts workspace name input to owner/workspace.agent format
14541454
// Possible valid input formats:
14551455
// workspace
1456+
// workspace.agent
14561457
// owner/workspace
14571458
// owner--workspace
14581459
// owner/workspace--agent
@@ -1467,7 +1468,11 @@ func normalizeWorkspaceInput(input string) string {
14671468
case 1:
14681469
return input // "workspace"
14691470
case 2:
1470-
return fmt.Sprintf("%s/%s", parts[0], parts[1]) // "owner/workspace"
1471+
// Either "owner/workspace" or "workspace.agent"
1472+
if strings.Contains(input, "/") || strings.Contains(input, "--") {
1473+
return fmt.Sprintf("%s/%s", parts[0], parts[1]) // owner/workspace
1474+
}
1475+
return fmt.Sprintf("%s.%s", parts[0], parts[1]) // workspace.agent
14711476
case 3:
14721477
return fmt.Sprintf("%s/%s.%s", parts[0], parts[1], parts[2]) // "owner/workspace.agent"
14731478
default:

cli/ssh_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,7 @@ func TestSSH(t *testing.T) {
106106

107107
cases := []string{
108108
"myworkspace",
109+
"myworkspace.dev",
109110
"myuser/myworkspace",
110111
"myuser--myworkspace",
111112
"myuser/myworkspace--dev",

0 commit comments

Comments
 (0)