If steam message content contains \n will lost content
tomtrije opened this issue · 6 comments
tomtrije commented
likes title describle
tomtrije commented
Bug is here:
chunk.split(/\n|\r\n|\r/).forEach(function(line) {
line = line.trimRight();
var index = line.indexOf(this.FIELD_SEPARATOR);
if (index <= 0) {
// Line was either empty, or started with a separator and is a comment.
// Either way, ignore.
return;
}
var field = line.substring(0, index);
if (!(field in e)) {
return;
}
var value = line.substring(index + 1).trimLeft();
if (field === 'data') {
e[field] += value;
} else {
e[field] = value;
}
}.bind(this));
tomtrije commented
if chunk data likes this, will lost \n(which in line3 and line4) in "data" field
event:add
id:7753781597103745505
data:
data:
data:something
tomtrije commented
also trimRight
and trimLeft
will cause lost blank character
visceraldesert commented
also
trimRight
andtrimLeft
will cause lost blank character
I just hit that problem in my implementation, I lost important blank spaces
rodrigovr commented
@tomtrije You can try my changes from PR #35
my repo is at https://github.com/rodrigovr/sse.js/tree/main but I will close the fork as soon as the changes are accepted here
mpetazzoni commented
Merged #35. Thanks @rodrigovr !