Skip to content

Commit 27cbf5c

Browse files
committed
Update cache.ts
1 parent 8000756 commit 27cbf5c

File tree

1 file changed

+2
-28
lines changed

1 file changed

+2
-28
lines changed

modules/runtime/server/cache.ts

Lines changed: 2 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -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

3334
type 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(/^\/v1\/packages\/npm\/(.+)$/)
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

Comments
 (0)