From d6c1960ab725cb5bc5b7b598581886cc23c0ac6f Mon Sep 17 00:00:00 2001 From: Asher Date: Mon, 9 Oct 2023 14:36:06 -0800 Subject: [PATCH] Handle ? in SSH config --- src/sshSupport.test.ts | 28 ++++++++++++++++++++++++++++ src/sshSupport.ts | 3 ++- 2 files changed, 30 insertions(+), 1 deletion(-) diff --git a/src/sshSupport.test.ts b/src/sshSupport.test.ts index e723eff9..c7feea8c 100644 --- a/src/sshSupport.test.ts +++ b/src/sshSupport.test.ts @@ -40,3 +40,31 @@ Host coder-vscode--* ProxyCommand: '/tmp/coder --header="X-FOO=bar" coder.dev', }) }) + +it("handles ? wildcards", () => { + const properties = computeSSHProperties( + "coder-vscode--testing", + `Host * + StrictHostKeyChecking yes + +Host i-???????? i-????????????????? + User test + +# --- START CODER VSCODE --- +Host coder-v?ode--* + StrictHostKeyChecking yes + Another=false +Host coder-v?code--* + StrictHostKeyChecking no + Another=true + ProxyCommand=/tmp/coder --header="X-BAR=foo" coder.dev +# --- END CODER VSCODE --- +`, + ) + + expect(properties).toEqual({ + Another: "true", + StrictHostKeyChecking: "yes", + ProxyCommand: '/tmp/coder --header="X-BAR=foo" coder.dev', + }) +}) diff --git a/src/sshSupport.ts b/src/sshSupport.ts index 8e30d0cf..67966f5a 100644 --- a/src/sshSupport.ts +++ b/src/sshSupport.ts @@ -85,7 +85,8 @@ export function computeSSHProperties(host: string, config: string): Record