fix: use htmlrewriter2 instead of HTMLRewriter for node compat (#26309)

This commit is contained in:
Brendan Allan 2026-05-13 11:28:08 +08:00 committed by GitHub
commit ad6a8a1850
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 42 additions and 29 deletions

View file

@ -91,4 +91,23 @@ describe("tool.webfetch", () => {
}),
),
)
it.instance("extracts text from html without scripts or styles", () =>
withFetch(
() =>
new Response(
"<html><head><style>.hidden{}</style><script>alert('x')</script></head><body>Hello <b>world</b></body></html>",
{
status: 200,
headers: { "content-type": "text/html; charset=utf-8" },
},
),
(url) =>
Effect.gen(function* () {
const result = yield* exec({ url: new URL("/page.html", url).toString(), format: "text" })
expect(result.output).toBe("Hello world")
expect(result.attachments).toBeUndefined()
}),
),
)
})