(authority: string)
| 323 | } |
| 324 | |
| 325 | export function parseConnectTarget(authority: string): { |
| 326 | host: string; |
| 327 | port: string; |
| 328 | } { |
| 329 | if (!authority) { |
| 330 | return { host: "", port: "" }; |
| 331 | } |
| 332 | |
| 333 | if (authority.startsWith("[")) { |
| 334 | const closeBracket = authority.indexOf("]"); |
| 335 | if (closeBracket === -1) { |
| 336 | return { host: "", port: "" }; |
| 337 | } |
| 338 | const host = authority.slice(1, closeBracket); |
| 339 | const afterBracket = authority.slice(closeBracket + 1); |
| 340 | if (afterBracket === "" || afterBracket === ":") { |
| 341 | return { host, port: "443" }; |
| 342 | } |
| 343 | if (afterBracket[0] !== ":") { |
| 344 | return { host: "", port: "" }; |
| 345 | } |
| 346 | return { host, port: afterBracket.slice(1) || "443" }; |
| 347 | } |
| 348 | |
| 349 | const lastColon = authority.lastIndexOf(":"); |
| 350 | if (lastColon === -1) { |
| 351 | return { host: authority, port: "443" }; |
| 352 | } |
| 353 | |
| 354 | const host = authority.slice(0, lastColon); |
| 355 | const port = authority.slice(lastColon + 1) || "443"; |
| 356 | return { host, port }; |
| 357 | } |
no outgoing calls
no test coverage detected
searching dependent graphs…