Skip to content

Commit 0485440

Browse files
committed
1 parent a54ca9e commit 0485440

File tree

3 files changed

+8
-5
lines changed

3 files changed

+8
-5
lines changed

package.json

+1
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
"parallelshell": "^2.0.0",
3535
"qs-iconv": "^1.0.4",
3636
"safe-publish-latest": "^1.1.1",
37+
"safer-buffer": "^2.0.2",
3738
"tape": "^4.6.3"
3839
},
3940
"scripts": {

test/parse.js

+3-2
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
var test = require('tape');
44
var qs = require('../');
55
var iconv = require('iconv-lite');
6+
var SaferBuffer = require('safer-buffer').Buffer;
67

78
test('parse()', function (t) {
89
t.test('parses a simple string', function (st) {
@@ -230,7 +231,7 @@ test('parse()', function (t) {
230231
});
231232

232233
t.test('parses buffers correctly', function (st) {
233-
var b = new Buffer('test');
234+
var b = SaferBuffer.from('test');
234235
st.deepEqual(qs.parse({ a: b }), { a: b });
235236
st.end();
236237
});
@@ -511,7 +512,7 @@ test('parse()', function (t) {
511512
result.push(parseInt(parts[1], 16));
512513
parts = reg.exec(str);
513514
}
514-
return iconv.decode(new Buffer(result), 'shift_jis').toString();
515+
return iconv.decode(SaferBuffer.from(result), 'shift_jis').toString();
515516
}
516517
}), { : '大阪府' });
517518
st.end();

test/stringify.js

+4-3
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
var test = require('tape');
44
var qs = require('../');
55
var iconv = require('iconv-lite');
6+
var SaferBuffer = require('safer-buffer').Buffer;
67

78
test('stringify()', function (t) {
89
t.test('stringifies a querystring object', function (st) {
@@ -325,8 +326,8 @@ test('stringify()', function (t) {
325326
});
326327

327328
t.test('stringifies buffer values', function (st) {
328-
st.equal(qs.stringify({ a: new Buffer('test') }), 'a=test');
329-
st.equal(qs.stringify({ a: { b: new Buffer('test') } }), 'a%5Bb%5D=test');
329+
st.equal(qs.stringify({ a: SaferBuffer.from('test') }), 'a=test');
330+
st.equal(qs.stringify({ a: { b: SaferBuffer.from('test') } }), 'a%5Bb%5D=test');
330331
st.end();
331332
});
332333

@@ -460,7 +461,7 @@ test('stringify()', function (t) {
460461
});
461462

462463
t.test('can use custom encoder for a buffer object', { skip: typeof Buffer === 'undefined' }, function (st) {
463-
st.equal(qs.stringify({ a: new Buffer([1]) }, {
464+
st.equal(qs.stringify({ a: SaferBuffer.from([1]) }, {
464465
encoder: function (buffer) {
465466
if (typeof buffer === 'string') {
466467
return buffer;

0 commit comments

Comments
 (0)