Skip to content

Commit

Permalink
Merge pull request #149 from emilbayes/master
Browse files Browse the repository at this point in the history
Fix bug with .fill bytes > 127 from other encoding
  • Loading branch information
feross committed Nov 7, 2016
2 parents bb6ff63 + 445e607 commit dd972aa
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 2 deletions.
3 changes: 2 additions & 1 deletion README.md
Expand Up @@ -328,7 +328,8 @@ Then, to run tests in Node.js, run:

To test locally in a browser, you can run:

npm run test-browser-local
npm run test-browser-es5-local # For ES5 browsers that don't support ES6
npm run test-browser-es6-local # For ES6 compliant browsers

This will print out a URL that you can then open in a browser to run the tests, using [Zuul](https://github.com/defunctzombie/zuul).

Expand Down
2 changes: 1 addition & 1 deletion index.js
Expand Up @@ -1544,7 +1544,7 @@ Buffer.prototype.fill = function fill (val, start, end, encoding) {
} else {
var bytes = Buffer.isBuffer(val)
? val
: utf8ToBytes(new Buffer(val, encoding).toString())
: new Buffer(val, encoding)
var len = bytes.length
for (i = 0; i < end - start; ++i) {
this[i + start] = bytes[i % len]
Expand Down
9 changes: 9 additions & 0 deletions test/base64.js
Expand Up @@ -44,3 +44,12 @@ test('base64: invalid non-alphanumeric characters -- should be stripped', functi
)
t.end()
})

test('base64: high byte', function (t) {
var highByte = B.from([128])
t.deepEqual(
B.alloc(1, highByte.toString('base64'), 'base64'),
highByte
)
t.end()
})

0 comments on commit dd972aa

Please sign in to comment.