Alorel / shrink-ray

Node.js compression middleware
MIT License
177 stars 16 forks source link

Comma is inserted into the encoded text #64

Open FerencDenes opened 1 year ago

FerencDenes commented 1 year ago

When compressing an xml file (probably other formats as well) with all 3 schemes (br, gzip, deflate) a "," is inserted into the text:

<?xml version="1.0" encoding="UTF-8"?>

abc-0 abc-1 abc-2 abc-3 ... abc-564 abc-565 abc-566 **abc-567** abc-568 abc-569 false

When switching off the middleware it did not happen.

This is how to repro:

const express = require("express");
const app = express();
const port = 3000;
const querystring = require("querystring");
const shrinkRay = require("shrink-ray-current");

app.use(shrinkRay());

app.get("/xml/:size", (req, res) => {
  let xml = '<?xml version="1.0" encoding="UTF-8"?>';
  xml += "<foo>";
  for (let i = 0; i < req.params.size; ++i) {
    xml += `<bar naaa="foo">abc-${i}</bar>`;
  }
  xml += `<bar>false</bar>`;
  xml += "</foo>";
  res.header("Content-Type", "application/xml");
  res.status(200).send(xml);
});

app.listen(port, () => {
  console.log(`Example app listening on port ${port}`);
});