mirror of
https://github.com/stablyai/orca.git
synced 2026-10-21 00:03:46 +00:00
Unify owner validation across project pickers and repository overrides. Preserve EMU usernames in API and auth-status branch-prefix resolution, with regression coverage. Co-authored-by: Neil <neil@stably.ai>
22 lines
687 B
TypeScript
22 lines
687 B
TypeScript
import { GITHUB_OWNER_SLUG_RE } from '../../shared/github/owner-slug'
|
|
import type { GitHubOwnerRepo } from '../../shared/github/pull-request-types'
|
|
|
|
export type GitHubApiRepositoryResolution =
|
|
| GitHubOwnerRepo
|
|
| null
|
|
| undefined
|
|
| (() => Promise<GitHubOwnerRepo | null>)
|
|
|
|
// Why: renderer/RPC overrides reach authenticated REST paths.
|
|
const OWNER_SLUG_RE = GITHUB_OWNER_SLUG_RE
|
|
const REPOSITORY_SLUG_RE = /^[A-Za-z0-9._-]+$/
|
|
|
|
export function isValidGitHubApiRepository(repository: GitHubOwnerRepo): boolean {
|
|
return (
|
|
OWNER_SLUG_RE.test(repository.owner) &&
|
|
REPOSITORY_SLUG_RE.test(repository.repo) &&
|
|
repository.repo !== '.' &&
|
|
repository.repo !== '..'
|
|
)
|
|
}
|