diff --git a/.travis.yml b/.travis.yml index d4dedd6..296bd19 100644 --- a/.travis.yml +++ b/.travis.yml @@ -6,6 +6,7 @@ node_js: - "0.12" - "4" - "5" + - "6" env: matrix: - TEST_SUITE=unit diff --git a/index.js b/index.js index 9cd6a70..914af68 100644 --- a/index.js +++ b/index.js @@ -41,7 +41,7 @@ HashBase.prototype._flush = function (callback) { HashBase.prototype.update = function (data, encoding) { if (!Buffer.isBuffer(data) && typeof data !== 'string') throw new TypeError('Data must be a string or a buffer') if (this._finalized) throw new Error('Digest already called') - if (!Buffer.isBuffer(data)) data = new Buffer(data, encoding || 'binary') + if (!Buffer.isBuffer(data)) data = new Buffer(data, encoding) // consume data var block = this._block diff --git a/test/index.js b/test/index.js index 5cd9c93..18798d1 100644 --- a/test/index.js +++ b/test/index.js @@ -1,5 +1,5 @@ 'use strict' -var test = require('tape').test +var test = require('tape') var HashBase = require('../') function beforeEach (t) { @@ -87,11 +87,13 @@ test('update', function (t) { t.end() }) - t.test('decode string with binary by default', function (t) { + t.test('decode string with utf8 by default', function (t) { t.plan(1) var buffer = new Buffer(64) + buffer.fill(0) + new Buffer('УТФ-8', 'utf8').copy(buffer) t.base._update = function () { t.same(this._block, buffer) } - t.base.update(buffer.toString('binary')) + t.base.update(buffer.toString('utf8')) t.end() })