Files
secustor d198ccdcf7 refactor(util): share the api.github.com token lookup
Add `findGithubComHostRule()` and `findGithubComToken()` to
`lib/util/check-token.ts`, backed by a new exported `GITHUB_API_URL`
constant, and use them at every site that looked up the `github`
host rule for `https://api.github.com/` by hand:
`nix`, `mise` and `composer` artifacts, `github-actions` artifacts
(`getTokenEnv`'s github.com branch; the GitHub Enterprise Server
branch keeps its own generic `findToken(url)` helper unchanged),
`npm` post-update, and `lib/util/git/auth.ts`.

No behaviour change:
- Sites that only needed the normalized token (nix, mise,
  github-actions) now call `findGithubComToken()`.
- Sites that need the full host rule (composer, npm post-update,
  git/auth) now call `findGithubComHostRule()`, preserving their
  existing use of the raw `token` field or `isArtifactAuthEnabled()`
  checks.
- `checkGithubToken()` in the same file keeps its own
  `hostRules.find({ hostType: 'github', url: 'https://api.github.com' })`
  call (note: no trailing slash) untouched, since it isn't one of the
  duplicated call sites and switching it to the new constant would
  change the matched URL.

Covered by new `findGithubComHostRule`/`findGithubComToken` spec
cases in `lib/util/check-token.spec.ts`. No other spec needed
changes: all affected callers' specs configure host rules through
the real `hostRules.add()` rather than mocking the lookup.
2026-09-14 22:43:31 +02:00
..