Skip to content

working with buffer?Β #13

@cekvenich

Description

@cekvenich

Hi, very nice lib, I'm using it, works. I need help. Here is what I have, just some debug code that does nothing:

      const transformerFunction = function (data, req, res) {
         for(var prop in req) {
            console.log(prop) // to see if I can tell the query string.
         }
         //<script src="/reload/reload.js"></script>
         let str = data.toString('utf8')
         console.log(str)
         return Buffer.from( str, 'utf8' )
      }

How do I work with buffer?
First I want to ignore anything that is not dealing with html, eg: images and just return.
What is a good way to detect css, images, etc?

Second, if it might be html, I want to append string <script src="/reload/reload.js"></script> to in the middle of the response string. I plan just to use string functions.
I am not worried about performance as this is a dev server.
Do I need to assemble all the buffers somehow into a full body string?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions