Skip to content

Commit

Permalink
utf-8 is default in Buffer.from
Browse files Browse the repository at this point in the history
  • Loading branch information
mafintosh committed Mar 6, 2018
1 parent b2b295f commit 9791961
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion example.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const turbo = require('./')

const hello = 'hello world\n'
const hello = Buffer.from('hello world\n')

turbo.createServer(function (req, res) {
res.setHeader('Content-Length', hello.length)
Expand Down
4 changes: 2 additions & 2 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ class Response {
}

write (buf, n, cb) {
if (typeof buf === 'string') buf = Buffer.from(buf, 'utf8')
if (typeof buf === 'string') buf = Buffer.from(buf)
if (typeof n === 'function') this._write(buf, buf.length, n)
else this._write(buf, n || buf.length, cb)
}
Expand Down Expand Up @@ -193,7 +193,7 @@ class Response {
}

end (buf, n, cb) {
if (typeof buf === 'string') buf = Buffer.from(buf, 'utf8')
if (typeof buf === 'string') buf = Buffer.from(buf)
if (!buf) this._end(EMPTY, 0, undefined)
else if (typeof buf === 'function') this._end(EMPTY, 0, buf)
else if (typeof n === 'function') this._end(buf, buf.length, n)
Expand Down

0 comments on commit 9791961

Please sign in to comment.