From 0bc4b3c58713218f4936378195aba356883099bd Mon Sep 17 00:00:00 2001 From: btea <2356281422@qq.com> Date: Sat, 13 Dec 2025 19:05:42 +0800 Subject: [PATCH] test: pkg.pr.new redirect to relative path (#10309) --- network/fetch/test/fetchFromRegistry.test.ts | 22 ++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/network/fetch/test/fetchFromRegistry.test.ts b/network/fetch/test/fetchFromRegistry.test.ts index 7281e37da9..2812934c53 100644 --- a/network/fetch/test/fetchFromRegistry.test.ts +++ b/network/fetch/test/fetchFromRegistry.test.ts @@ -177,6 +177,28 @@ test('redirect to relative URL', async () => { expect(nock.isDone()).toBeTruthy() }) +test('redirect to relative URL when request pkg.pr.new link', async () => { + nock('https://pkg.pr.new/') + .get('/vue@14175') + .reply(302, '', { location: '/vuejs/core/vue@14182' }) + + nock('https://pkg.pr.new/') + .get('/vuejs/core/vue@14182') + .reply(302, '', { location: '/vuejs/core/vue@82a13bb6faaa9f77a06b57e69e0934b9f620f333' }) + + nock('https://pkg.pr.new/') + .get('/vuejs/core/vue@82a13bb6faaa9f77a06b57e69e0934b9f620f333') + .reply(200, { ok: true }) + + const fetchFromRegistry = createFetchFromRegistry({ fullMetadata: true }) + const res = await fetchFromRegistry( + 'https://pkg.pr.new/vue@14175' + ) + + expect(await res.json()).toStrictEqual({ ok: true }) + expect(nock.isDone()).toBeTruthy() +}) + test('redirect without location header throws error', async () => { nock('http://registry.pnpm.io/') .get('/missing-location')