Skip to content

Commit da96426

Browse files
committed
Merge pull request #4 from crypto-browserify/fix/node-v6
utf8 as default encoding
2 parents a6506b4 + 5d95d75 commit da96426

File tree

3 files changed

+7
-4
lines changed

3 files changed

+7
-4
lines changed

.travis.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ node_js:
66
- "0.12"
77
- "4"
88
- "5"
9+
- "6"
910
env:
1011
matrix:
1112
- TEST_SUITE=unit

index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ HashBase.prototype._flush = function (callback) {
4141
HashBase.prototype.update = function (data, encoding) {
4242
if (!Buffer.isBuffer(data) && typeof data !== 'string') throw new TypeError('Data must be a string or a buffer')
4343
if (this._finalized) throw new Error('Digest already called')
44-
if (!Buffer.isBuffer(data)) data = new Buffer(data, encoding || 'binary')
44+
if (!Buffer.isBuffer(data)) data = new Buffer(data, encoding)
4545

4646
// consume data
4747
var block = this._block

test/index.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
'use strict'
2-
var test = require('tape').test
2+
var test = require('tape')
33
var HashBase = require('../')
44

55
function beforeEach (t) {
@@ -87,11 +87,13 @@ test('update', function (t) {
8787
t.end()
8888
})
8989

90-
t.test('decode string with binary by default', function (t) {
90+
t.test('decode string with utf8 by default', function (t) {
9191
t.plan(1)
9292
var buffer = new Buffer(64)
93+
buffer.fill(0)
94+
new Buffer('УТФ-8', 'utf8').copy(buffer)
9395
t.base._update = function () { t.same(this._block, buffer) }
94-
t.base.update(buffer.toString('binary'))
96+
t.base.update(buffer.toString('utf8'))
9597
t.end()
9698
})
9799

0 commit comments

Comments
 (0)