(stdout: string)
| 279 | } |
| 280 | |
| 281 | function parsePullRequest(stdout: string): PullRequestInfo | null { |
| 282 | try { |
| 283 | const raw = JSON.parse(stdout) as unknown; |
| 284 | if (typeof raw !== 'object' || raw === null) return null; |
| 285 | const record = raw as Record<string, unknown>; |
| 286 | const number = record['number']; |
| 287 | const url = record['url']; |
| 288 | if (typeof number !== 'number' || !Number.isInteger(number) || number <= 0) return null; |
| 289 | if (typeof url !== 'string' || !isSafeHttpUrl(url)) return null; |
| 290 | return { number, url }; |
| 291 | } catch { |
| 292 | return null; |
| 293 | } |
| 294 | } |
| 295 | |
| 296 | function isSafeHttpUrl(value: string): boolean { |
| 297 | if (hasControlChars(value)) return false; |
no test coverage detected