Skip to content

Commit 0423107

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 0423107

File tree

3 files changed

+16
-4
lines changed

3 files changed

+16
-4
lines changed

.eslintrc.json

+7-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,13 @@
3535
}],
3636
"import/no-unresolved": ["error", {
3737
"ignore": ["vscode"]
38-
}]
38+
}],
39+
"@typescript-eslint/no-unused-vars": [
40+
"error",
41+
{
42+
"varsIgnorePattern": "^_"
43+
}
44+
]
3945
},
4046
"ignorePatterns": [
4147
"out",

src/sshSupport.test.ts

+2
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

+7-3
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)