Commit 2f7a3b05a9

2f7a3b05a97d33a01fda463fa4f6c0375aaeaf56

parent: 692015e858

Unsigned

Alicia Sykes <alicia@omg.lol> · 2026-10-11 17:17 UTC

Fixes non-200 website checks no get cached

Layout: unified · split

api/src/lib/page.ts +2 −1
@@ -109,7 +109,8 @@ export const fetchPage = async (target: string): Promise<Page> => {
109109 url = new URL(location, url)
110110 continue
111111 }
112 if (!res.ok) {
112 // Only a 200 is the page itself, other 2xx are interstitials
113 if (res.status !== 200) {
113114 throw new ApiError(
114115 'UPSTREAM_ERROR',
115116 `${url.hostname} returned ${res.status}`,
api/tests/trackers.test.ts +3 −2
@@ -221,8 +221,8 @@ describe('isPrivateIp', () => {
221221 })
222222})
223223
224const html = (body: BodyInit) =>
225 new Response(body, { headers: { 'content-type': 'text/html' } })
224const html = (body: BodyInit, status = 200) =>
225 new Response(body, { status, headers: { 'content-type': 'text/html' } })
226226const redirect = (location: string) =>
227227 new Response(null, { status: 301, headers: { location } })
228228
@@ -285,6 +285,7 @@ describe('fetchPage', () => {
285285 it('rejects error statuses, non-HTML and network failures as 502', async () => {
286286 for (const respond of [
287287 async () => new Response('nope', { status: 404 }),
288 async () => html('<p>hi</p>', 202),
288289 async () =>
289290 new Response('%PDF', { headers: { 'content-type': 'application/pdf' } }),
290291 async () => Promise.reject(new TypeError('fetch failed')),