Skip to content

Commit 8b4e951

Browse files
committed
Fix equals being lost in SSH config value
This was causing issues with the header flag as those contain equal signs.
1 parent 337418d commit 8b4e951

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

src/sshSupport.test.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,12 +29,14 @@ it("computes the config for a host", () => {
2929
Host coder-vscode--*
3030
StrictHostKeyChecking no
3131
Another=true
32+
ProxyCommand=/tmp/coder --header="X-FOO=bar" coder.dev
3233
# --- END CODER VSCODE ---
3334
`,
3435
)
3536

3637
expect(properties).toEqual({
3738
Another: "true",
3839
StrictHostKeyChecking: "yes",
40+
ProxyCommand: '/tmp/coder --header="X-FOO=bar" coder.dev'
3941
})
4042
})

src/sshSupport.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,11 @@ export function computeSSHProperties(host: string, config: string): Record<strin
5252
if (line === "") {
5353
return
5454
}
55-
const [key, ...valueParts] = line.split(/\s+|=/)
55+
// The capture group here will include the captured portion in the array
56+
// which we need to join them back up with their original values. The first
57+
// separate is ignored since it splits the key and value but is not part of
58+
// the value itself.
59+
const [key, _, ...valueParts] = line.split(/(\s+|=)/)
5660
if (key.startsWith("#")) {
5761
// Ignore comments!
5862
return
@@ -62,15 +66,15 @@ export function computeSSHProperties(host: string, config: string): Record<strin
6266
configs.push(currentConfig)
6367
}
6468
currentConfig = {
65-
Host: valueParts.join(" "),
69+
Host: valueParts.join(""),
6670
properties: {},
6771
}
6872
return
6973
}
7074
if (!currentConfig) {
7175
return
7276
}
73-
currentConfig.properties[key] = valueParts.join(" ")
77+
currentConfig.properties[key] = valueParts.join("")
7478
})
7579
if (currentConfig) {
7680
configs.push(currentConfig)

0 commit comments

Comments
 (0)