MCPcopy Index your code
hub / github.com/coder/coder / NormalizeWorkspaceInput

Function NormalizeWorkspaceInput

codersdk/toolsdk/toolsdk.go:2488–2503  ·  view source on GitHub ↗

NormalizeWorkspaceInput converts workspace name input to standard format. Handles the following input formats: - workspace → workspace - workspace.agent → workspace.agent - owner/workspace → owner/workspace - owner--workspace → owner/workspace

(input string)

Source from the content-addressed store, hash-verified

2486// - owner--workspace.agent → owner/workspace.agent
2487// - agent.workspace.owner → owner/workspace.agent (Coder Connect format)
2488func NormalizeWorkspaceInput(input string) string {
2489 // Handle the special Coder Connect format: agent.workspace.owner
2490 // This format uses only dots and has exactly 3 parts
2491 if strings.Count(input, ".") == 2 && !strings.Contains(input, "/") && !strings.Contains(input, "--") {
2492 parts := strings.Split(input, ".")
2493 if len(parts) == 3 {
2494 // Convert agent.workspace.owner → owner/workspace.agent
2495 return fmt.Sprintf("%s/%s.%s", parts[2], parts[1], parts[0])
2496 }
2497 }
2498
2499 // Convert -- separator to / separator for consistency
2500 normalized := strings.ReplaceAll(input, "--", "/")
2501
2502 return normalized
2503}
2504
2505const workspaceDescription = "The workspace ID or name in the format [owner/]workspace. If an owner is not specified, the authenticated user is used."
2506

Callers 3

openAgentConnFunction · 0.85
toolsdk.goFile · 0.85

Calls 2

CountMethod · 0.80
ContainsMethod · 0.45

Tested by 1