Skip to content

Commit

Permalink
Merge pull request #12 from Level/fix/utf8-decoding
Browse files Browse the repository at this point in the history
Fix/utf8 decoding
  • Loading branch information
juliangruber authored Jan 26, 2017
2 parents f4d3585 + e60d03f commit 2278dce
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
6 changes: 5 additions & 1 deletion lib/encodings.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,11 @@ exports.utf8 = exports['utf-8'] = {
? data
: String(data);
},
decode: identity,
decode: function(data){
return typeof data === 'string'
? data
: String(data)
},
buffer: false,
type: 'utf8'
};
Expand Down
5 changes: 5 additions & 0 deletions test/kv.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,11 @@ test('decode value', function(t){
});
t.equal(buf.toString(), 'hey');

buf = codec.decodeValue(new Buffer('hey'), {
valueEncoding: 'utf8'
});
t.equal(buf, 'hey');

t.end();
});

Expand Down

0 comments on commit 2278dce

Please sign in to comment.