(input: string)
| 114 | return `ssh-keyscan -p ${port} ${domain} >> ${knownHostsPath};`; |
| 115 | }; |
| 116 | const sanitizeRepoPathSSH = (input: string) => { |
| 117 | const SSH_PATH_RE = new RegExp( |
| 118 | [ |
| 119 | /^\s*/, |
| 120 | /(?:(?<proto>[a-z]+):\/\/)?/, |
| 121 | /(?:(?<user>[a-z_][a-z0-9_-]+)@)?/, |
| 122 | /(?<domain>[^\s/?#:]+)/, |
| 123 | /(?::(?<port>[0-9]{1,5}))?/, |
| 124 | /(?:[/:](?<owner>[^\s/?#:]+))?/, |
| 125 | /(?:[/:](?<repo>(?:[^\s?#:.]|\.(?!git\/?\s*$))+))/, |
| 126 | /(?:.git)?\/?\s*$/, |
| 127 | ] |
| 128 | .map((r) => r.source) |
| 129 | .join(""), |
| 130 | "i", |
| 131 | ); |
| 132 | |
| 133 | const found = input.match(SSH_PATH_RE); |
| 134 | if (!found) { |
| 135 | throw new Error(`Malformatted SSH path: ${input}`); |
| 136 | } |
| 137 | |
| 138 | return { |
| 139 | user: found.groups?.user ?? "git", |
| 140 | domain: found.groups?.domain, |
| 141 | port: Number(found.groups?.port ?? 22), |
| 142 | owner: found.groups?.owner ?? "", |
| 143 | repo: found.groups?.repo, |
| 144 | get repoPath() { |
| 145 | return `ssh://${this.user}@${this.domain}:${this.port}/${this.owner}${ |
| 146 | this.owner && "/" |
| 147 | }${this.repo}.git`; |
| 148 | }, |
| 149 | }; |
| 150 | }; |
| 151 | |
| 152 | interface Props { |
| 153 | appName: string; |
no outgoing calls
no test coverage detected