(value: string, sourceLabel: string)
| 69 | } |
| 70 | |
| 71 | function parseRepositorySlug(value: string, sourceLabel: string): { owner: string; repo: string } { |
| 72 | const separator = value.indexOf('/'); |
| 73 | if ( |
| 74 | separator <= 0 || |
| 75 | separator === value.length - 1 || |
| 76 | value.indexOf('/', separator + 1) !== -1 |
| 77 | ) { |
| 78 | throw new AppError('INVALID_ARGS', `${sourceLabel} must use owner/repo.`); |
| 79 | } |
| 80 | const result = { |
| 81 | owner: value.slice(0, separator).trim(), |
| 82 | repo: value.slice(separator + 1).trim(), |
| 83 | }; |
| 84 | if (!result.owner || !result.repo) { |
| 85 | throw new AppError('INVALID_ARGS', `${sourceLabel} must use owner/repo.`); |
| 86 | } |
| 87 | return result; |
| 88 | } |
| 89 | |
| 90 | function readText(value: unknown): string | undefined { |
| 91 | return typeof value === 'string' && value.trim().length > 0 ? value.trim() : undefined; |
no outgoing calls
no test coverage detected