Skip to content

Commit

Permalink
fix(middleware): update Buffer usage
Browse files Browse the repository at this point in the history
Update Buffer usage to non-deprecated methods of creating a Buffer, polyfilling with `safer-buffer`.
  • Loading branch information
wesleycho authored and dignifiedquire committed Dec 7, 2016
1 parent d1a167f commit 3d94b8c
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
5 changes: 3 additions & 2 deletions lib/middleware/common.js
Expand Up @@ -5,6 +5,7 @@
var mime = require('mime')
var _ = require('lodash')
var parseRange = require('range-parser')
var Buffer = require('safe-buffer').Buffer

var log = require('../logger').create('web-server')

Expand Down Expand Up @@ -40,10 +41,10 @@ var createServeFile = function (fs, directory, config) {
return 200
} else if (range === -1) {
// unsatisfiable range
responseData = new Buffer(0)
responseData = Buffer.alloc(0)
return 416
} else if (range.type === 'bytes') {
responseData = new Buffer(responseData)
responseData = Buffer.from(responseData)
if (range.length === 1) {
var start = range[0].start
var end = range[0].end
Expand Down
1 change: 1 addition & 0 deletions package.json
Expand Up @@ -320,6 +320,7 @@
"qjobs": "^1.1.4",
"range-parser": "^1.2.0",
"rimraf": "^2.3.3",
"safe-buffer": "^5.0.1",
"socket.io": "1.7.1",
"source-map": "^0.5.3",
"tmp": "0.0.28",
Expand Down

0 comments on commit 3d94b8c

Please sign in to comment.