Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

working with buffer? #13

Open
cekvenich opened this issue Oct 14, 2018 · 0 comments
Open

working with buffer? #13

cekvenich opened this issue Oct 14, 2018 · 0 comments

Comments

@cekvenich
Copy link

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant