Skip to content

Commit 412a3bf

Browse files
committed
fix(ssh): accept mixed-case URI schemes
1 parent 07e83b6 commit 412a3bf

2 files changed

Lines changed: 5 additions & 2 deletions

File tree

‎packages/ssh/src/command.test.ts‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,13 +89,16 @@ describe("ssh command", () => {
8989
for (const [alias, hostname, expected] of [
9090
["ssh://host.example:2222", "host.example", "[email protected]"],
9191
["ssh://[::1]:2222", "::1", "alice@::1"],
92+
["SSH://host.example:2222", "host.example", "[email protected]"],
93+
["SsH://[::1]:2222", "::1", "alice@::1"],
9294
]) {
9395
const resolved = parseSshResolveOutput(
9496
alias!,
9597
`hostname ${hostname}\nuser alice\nport 2222\n`,
9698
);
9799
assert.equal(yield* buildSshHostSpecEffect(resolved), expected);
98100
assert.include(baseSshArgs(resolved), "2222");
101+
assert.include(baseSshArgs({ ...resolved, port: null }), "2222");
99102
}
100103
}),
101104
);

‎packages/ssh/src/command.ts‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,10 +85,10 @@ function parseSshDestination(target: DesktopSshEnvironmentTarget) {
8585
if (destination.length === 0) {
8686
throw new Error("SSH target is missing its alias/hostname.");
8787
}
88-
if (!destination.startsWith("ssh://")) {
88+
if (!/^ssh:\/\//iu.test(destination)) {
8989
return { hostname: destination, username: target.username, port: target.port };
9090
}
91-
const authority = /^ssh:\/\/(?:([^@/?#:]+)@)?(\[[^\]]+\]|[^:/?#@]+)(?::(\d+))?\/?$/u.exec(
91+
const authority = /^ssh:\/\/(?:([^@/?#:]+)@)?(\[[^\]]+\]|[^:/?#@]+)(?::(\d+))?\/?$/iu.exec(
9292
destination,
9393
);
9494
if (!authority?.[2]) throw new Error("SSH URI is invalid.");

0 commit comments

Comments
 (0)