The best way to control Claude Code, Codex and more from any computer or phone
Mirrored from https://github.com/Camo67/t3code.git
Synced Nov 21, 03:37 UTC
| 1 | const SCP_SSH_REMOTE_PATTERN = /^[a-zA-Z0-9._-]+@([^:/]+):/; |
| 2 | // Git reads `host:path` as SSH too, leaving the user to ssh config. A single letter is a Windows |
| 3 | // drive and `::` names a remote helper. |
| 4 | const USERLESS_SCP_SSH_REMOTE_PATTERN = /^([^@:/\\\s]{2,}):(?!:)\/?[^/\s]+(?:\/[^/\s]+)*\/?$/u; |
| 5 | |
| 6 | /** Null unless the remote is `host:path`, with no user. */ |
| 7 | export function userlessScpRemoteHost(remoteUrl: string): string | null { |
| 8 | return USERLESS_SCP_SSH_REMOTE_PATTERN.exec(remoteUrl.trim())?.[1] ?? null; |
| 9 | } |
| 10 | |
| 11 | export function isSshRemoteUrl(remoteUrl: string): boolean { |
| 12 | const trimmed = remoteUrl.trim(); |
| 13 | return ( |
| 14 | SCP_SSH_REMOTE_PATTERN.test(trimmed) || |
| 15 | trimmed.toLowerCase().startsWith("ssh://") || |
| 16 | userlessScpRemoteHost(trimmed) !== null |
| 17 | ); |
| 18 | } |