Skip to content

Commit 081a3ab

Browse files
committed
1 parent 943e411 commit 081a3ab

File tree

3 files changed

+16
-14
lines changed

3 files changed

+16
-14
lines changed

package.json

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,16 +24,18 @@
2424
},
2525
"dependencies": {},
2626
"devDependencies": {
27+
"@ljharb/eslint-config": "^6.0.0",
2728
"browserify": "^13.0.1",
28-
"tape": "^4.6.0",
2929
"covert": "^1.1.0",
30-
"mkdirp": "^0.5.1",
3130
"eslint": "^3.1.0",
32-
"@ljharb/eslint-config": "^6.0.0",
33-
"parallelshell": "^2.0.0",
31+
"evalmd": "^0.0.17",
3432
"iconv-lite": "^0.4.13",
35-
"qs-iconv": "^1.0.3",
36-
"evalmd": "^0.0.17"
33+
"mkdirp": "^0.5.1",
34+
"parallelshell": "^2.0.0",
35+
"qs-iconv": "^1.0.4",
36+
"safe-publish-latest": "^1.1.1",
37+
"safer-buffer": "^2.0.2",
38+
"tape": "^4.6.3"
3739
},
3840
"scripts": {
3941
"pretest": "npm run --silent readme && npm run --silent lint",

test/parse.js

Lines changed: 3 additions & 2 deletions
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) {
@@ -221,7 +222,7 @@ test('parse()', function (t) {
221222
});
222223

223224
t.test('parses buffers correctly', function (st) {
224-
var b = new Buffer('test');
225+
var b = SaferBuffer.from('test');
225226
st.deepEqual(qs.parse({ a: b }), { a: b });
226227
st.end();
227228
});
@@ -501,7 +502,7 @@ test('parse()', function (t) {
501502
result.push(parseInt(parts[1], 16));
502503
last = parts.index + parts[0].length;
503504
}
504-
return iconv.decode(new Buffer(result), 'shift_jis').toString();
505+
return iconv.decode(SaferBuffer.from(result), 'shift_jis').toString();
505506
}
506507
}), { : '大阪府' });
507508
st.end();

test/stringify.js

Lines changed: 5 additions & 6 deletions
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) {
@@ -193,8 +194,8 @@ test('stringify()', function (t) {
193194
});
194195

195196
t.test('stringifies buffer values', function (st) {
196-
st.equal(qs.stringify({ a: new Buffer('test') }), 'a=test');
197-
st.equal(qs.stringify({ a: { b: new Buffer('test') } }), 'a%5Bb%5D=test');
197+
st.equal(qs.stringify({ a: SaferBuffer.from('test') }), 'a=test');
198+
st.equal(qs.stringify({ a: { b: SaferBuffer.from('test') } }), 'a%5Bb%5D=test');
198199
st.end();
199200
});
200201

@@ -288,10 +289,8 @@ test('stringify()', function (t) {
288289
st.end();
289290
});
290291

291-
t.test('can use custom encoder for a buffer object', {
292-
skip: typeof Buffer === 'undefined'
293-
}, function (st) {
294-
st.equal(qs.stringify({ a: new Buffer([1]) }, {
292+
t.test('can use custom encoder for a buffer object', { skip: typeof Buffer === 'undefined' }, function (st) {
293+
st.equal(qs.stringify({ a: SaferBuffer.from([1]) }, {
295294
encoder: function (buffer) {
296295
if (typeof buffer === 'string') {
297296
return buffer;

0 commit comments

Comments
 (0)