Skip to content

Commit 942930f

Browse files
authored
Merge pull request #139 from Rud5G/sec-fix-buffer
Update the 'Buffer' calls, fix the DeprecationWarning
2 parents 03f1b35 + 14d4b17 commit 942930f

File tree

4 files changed

+4
-4
lines changed

4 files changed

+4
-4
lines changed

bin/webpagetest

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ var formatData = function(err, data, info) {
4040
} else if (info) {
4141
encoding = info.encoding;
4242
if (encoding === 'binary') {
43-
data = new Buffer(data, 'binary');
43+
data = new Buffer.from(data, 'binary');
4444
type = info.type;
4545
} else {
4646
data = {type: info.type, data: data};

lib/helper.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ function netLogParser(data) {
129129

130130
// Convert image (binary) into data URI (string)
131131
function dataURI(data) {
132-
return new Buffer(data || '', 'binary').toString('base64');
132+
return new Buffer.from(data || '', 'binary').toString('base64');
133133
}
134134

135135
// Convert script objects into formatted string

lib/server.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ function output(callback, err, data, info) {
3939
code = err.code || code;
4040
} else if (info) {
4141
if (info.encoding === 'binary') {
42-
data = new Buffer(data, 'binary');
42+
data = new Buffer.from(data, 'binary');
4343
type = info.type;
4444
} else {
4545
data = {type: info.type, data: data};

lib/webpagetest.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ function get(config, pathname, proxy, agent, callback, encoding) {
119119

120120
res.on('end', function onEnd() {
121121
var i, len, pos,
122-
buffer = new Buffer(length),
122+
buffer = new Buffer.alloc(length),
123123
type = (res.headers['content-type'] || '').split(';')[0];
124124

125125
for (i = 0, len = data.length, pos = 0; i < len; i += 1) {

0 commit comments

Comments
 (0)