@@ -25,6 +25,7 @@ const FIXTURE_PATHS = {
2525 user : 'users' ,
2626 esmHeaders : 'esm-sh:headers' ,
2727 esmTypes : 'esm-sh:types' ,
28+ githubContributors : 'github:contributors.json' ,
2829} as const
2930
3031type FixtureType = keyof typeof FIXTURE_PATHS
@@ -156,6 +157,13 @@ function getMockForUrl(url: string): MockResult | null {
156157 return { data : null }
157158 }
158159
160+ // GitHub API - handled via fixtures, return null to use fixture system
161+ // Note: The actual fixture loading is handled in fetchFromFixtures via special case
162+ if ( host === 'api.github.com' ) {
163+ // Return null here so it goes through fetchFromFixtures which handles the fixture loading
164+ return null
165+ }
166+
159167 // esm.sh is handled specially via $fetch.raw override, not here
160168 // Return null to indicate no mock available at the cachedFetch level
161169
@@ -273,6 +281,39 @@ async function handleFastNpmMeta(
273281 return { data : result }
274282}
275283
284+ /**
285+ * Handle GitHub API requests using fixtures.
286+ */
287+ async function handleGitHubApi (
288+ url : string ,
289+ storage : ReturnType < typeof useStorage > ,
290+ ) : Promise < MockResult | null > {
291+ let urlObj : URL
292+ try {
293+ urlObj = new URL ( url )
294+ } catch {
295+ return null
296+ }
297+
298+ const { host, pathname } = urlObj
299+
300+ if ( host !== 'api.github.com' ) return null
301+
302+ // Contributors endpoint: /repos/{owner}/{repo}/contributors
303+ const contributorsMatch = pathname . match ( / ^ \/ r e p o s \/ ( [ ^ / ] + ) \/ ( [ ^ / ] + ) \/ c o n t r i b u t o r s $ / )
304+ if ( contributorsMatch ) {
305+ const contributors = await storage . getItem < unknown [ ] > ( FIXTURE_PATHS . githubContributors )
306+ if ( contributors ) {
307+ return { data : contributors }
308+ }
309+ // Return empty array if no fixture exists
310+ return { data : [ ] }
311+ }
312+
313+ // Other GitHub API endpoints can be added here as needed
314+ return null
315+ }
316+
276317interface FixtureMatchWithVersion extends FixtureMatch {
277318 version ?: string // 'latest', a semver version, or undefined for full packument
278319}
@@ -385,6 +426,13 @@ async function fetchFromFixtures<T>(
385426 return { data : fastNpmMetaResult . data as T , isStale : false , cachedAt : Date . now ( ) }
386427 }
387428
429+ // Check for GitHub API
430+ const githubResult = await handleGitHubApi ( url , storage )
431+ if ( githubResult ) {
432+ if ( VERBOSE ) process . stdout . write ( `[test-fixtures] GitHub API: ${ url } \n` )
433+ return { data : githubResult . data as T , isStale : false , cachedAt : Date . now ( ) }
434+ }
435+
388436 const match = matchUrlToFixture ( url )
389437
390438 if ( ! match ) {
0 commit comments