fix(webfetch): avoid rewriting successful redirect content

This commit is contained in:
YeonGyu-Kim
2026-03-24 23:59:57 +09:00
parent af301ab29a
commit 971912e065
2 changed files with 20 additions and 2 deletions
@@ -49,7 +49,7 @@ function createFetchMock(
implementation: (input: RequestInfo | URL, init?: RequestInit) => Promise<Response>,
): typeof fetch {
return Object.assign(implementation, {
preconnect: originalFetch.preconnect,
preconnect: Reflect.get(originalFetch, "preconnect"),
})
}
@@ -152,6 +152,20 @@ describe("createWebFetchRedirectGuardHook", () => {
)
})
})
describe("#when successful fetched content mentions redirect loops", () => {
it("#then should keep the content unchanged", async () => {
const hook = createWebFetchRedirectGuardHook({} as never)
const input = createInput()
const output = createAfterOutput("This page explains why browsers hit too many redirects in some setups.")
await hook["tool.execute.after"](input, output)
expect(output.output).toBe(
"This page explains why browsers hit too many redirects in some setups.",
)
})
})
})
describe("#given a non-webfetch tool", () => {