Skip to content

Commit

Permalink
Forward any gibberish left in StringDecoder.
Browse files Browse the repository at this point in the history
  • Loading branch information
mcollina committed Jan 19, 2016
1 parent 6481984 commit a9825aa
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
3 changes: 3 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@ function transform (chunk, enc, cb) {
}

function flush (cb) {
// forward any gibberish left in there
this._last += this._decoder.end()

if (this._last) {
push(this, this.mapper(this._last))
}
Expand Down
2 changes: 1 addition & 1 deletion test.js
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,7 @@ test('truncated utf-8 char', function (t) {

input.pipe(strcb(function (err, list) {
t.error(err)
t.deepEqual(list, ['烫'])
t.deepEqual(list, ['烫' + new Buffer('e7', 'hex').toString()])
}))

var str = '烫烫'
Expand Down

0 comments on commit a9825aa

Please sign in to comment.