@@ -28,6 +28,7 @@ const FIXTURE_PATHS = {
2828 esmTypes : 'esm-sh:types' ,
2929 githubContributors : 'github:contributors.json' ,
3030 githubContributorsStats : 'github:contributors-stats.json' ,
31+ jsdelivr : 'jsdelivr' ,
3132} as const
3233
3334type FixtureType = keyof typeof FIXTURE_PATHS
@@ -163,33 +164,6 @@ function getMockForUrl(url: string): MockResult | null {
163164 }
164165 }
165166
166- // jsdelivr CDN - return 404 for README files, etc.
167- if ( host === 'cdn.jsdelivr.net' ) {
168- // Return null data which will cause a 404 - README files are optional
169- return { data : null }
170- }
171-
172- // jsdelivr data API - return mock file listing
173- if ( host === 'data.jsdelivr.com' ) {
174- const packageMatch = decodeURIComponent ( pathname ) . match ( / ^ \/ v 1 \/ p a c k a g e s \/ n p m \/ ( .+ ) $ / )
175- if ( packageMatch ?. [ 1 ] ) {
176- const pkgWithVersion = packageMatch [ 1 ]
177- const parsed = parseScopedPackageWithVersion ( pkgWithVersion )
178- return {
179- data : {
180- type : 'npm' ,
181- name : parsed . name ,
182- version : parsed . version || 'latest' ,
183- files : [
184- { name : 'package.json' , hash : 'abc123' , size : 1000 } ,
185- { name : 'index.js' , hash : 'def456' , size : 500 } ,
186- { name : 'README.md' , hash : 'ghi789' , size : 2000 } ,
187- ] ,
188- } ,
189- }
190- }
191- }
192-
193167 // Gravatar API - return 404 (avatars not needed in tests)
194168 if ( host === 'www.gravatar.com' ) {
195169 return { data : null }
@@ -590,7 +564,7 @@ async function handleJsdelivrDataApi(
590564 const parsed = parseScopedPackageWithVersion ( packageMatch [ 1 ] )
591565
592566 // Try per-package fixture first
593- const fixturePath = ` jsdelivr: ${ parsed . name . replace ( / \/ / g , ':' ) } .json`
567+ const fixturePath = getFixturePath ( ' jsdelivr' , parsed . name )
594568 const fixture = await storage . getItem < unknown > ( fixturePath )
595569 if ( fixture ) {
596570 return { data : fixture }
0 commit comments