Skip to content

HTMLRewriter doesn't support reading from a Blob #17259

@huseeiin

Description

@huseeiin

What version of Bun is running?

No response

What platform is your computer?

No response

What steps can reproduce the bug?

new HTMLRewriter()
  .on("script", {
    element(element) {
      console.log(element.getAttribute("src"));
    },
  })
  .transform(new Blob(['<script src="/main.js"></script>']));

What is the expected behavior?

this goes against the type signature of transform(input: Response | Blob | Bun.BufferSource): Response

What do you see instead?

TypeError: Expected Response or Body

Additional information

i also expected it to work with BunFile, but it doesn't:

new HTMLRewriter()
  .on("script", {
    element(element) {
      console.log(element.getAttribute("src"));
    },
  })
  .transform(Bun.file("index.html"));

also see https://bun.sh/docs/api/html-rewriter#input-types

Metadata

Metadata

Assignees

No one assigned

    Labels

    HTMLRewritercloudflare workers APIbugSomething isn't workingconfirmed bugWe can reproduce this issue

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions