Skip to content

Commit ad6ddca

Browse files
chore: ensure we use unix path
1 parent 3632b1b commit ad6ddca

File tree

2 files changed

+8
-7
lines changed

2 files changed

+8
-7
lines changed

cli/open.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -428,6 +428,8 @@ func buildVSCodeWorkspaceDevContainerLink(
428428
containerName string,
429429
containerFolder string,
430430
) (*url.URL, url.Values) {
431+
containerFolder = windowsToUnixPath(containerFolder)
432+
431433
qp := url.Values{}
432434
qp.Add("url", clientURL)
433435
qp.Add("owner", workspace.OwnerName)
@@ -520,6 +522,10 @@ func unixToWindowsPath(p string) string {
520522
return strings.ReplaceAll(p, "/", "\\")
521523
}
522524

525+
func windowsToUnixPath(p string) string {
526+
return strings.ReplaceAll(p, "\\", "/")
527+
}
528+
523529
// resolveAgentAbsPath resolves the absolute path to a file or directory in the
524530
// workspace. If the path is relative, it will be resolved relative to the
525531
// workspace's expanded directory. If the path is absolute, it will be returned

cli/open_test.go

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -185,11 +185,6 @@ func TestOpenVSCode_NoAgentDirectory(t *testing.T) {
185185
wd, err := os.Getwd()
186186
require.NoError(t, err)
187187

188-
absPath := "/home/coder"
189-
if runtime.GOOS == "windows" {
190-
absPath = "C:\\home\\coder"
191-
}
192-
193188
tests := []struct {
194189
name string
195190
args []string
@@ -210,8 +205,8 @@ func TestOpenVSCode_NoAgentDirectory(t *testing.T) {
210205
},
211206
{
212207
name: "ok with absolute path",
213-
args: []string{"--test.open-error", workspace.Name, absPath},
214-
wantDir: absPath,
208+
args: []string{"--test.open-error", workspace.Name, "/home/coder"},
209+
wantDir: "/home/coder",
215210
},
216211
{
217212
name: "ok with token",

0 commit comments

Comments
 (0)