Skip to content

Commit e967df6

Browse files
author
Florian Traverse
committed
clone options before any change to avoid issues
1 parent 0f9c6a1 commit e967df6

File tree

2 files changed

+11
-4
lines changed

2 files changed

+11
-4
lines changed

lib/index.js

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,17 @@
11
var qs = require('qs');
22
var url = require('url');
33
var crypto = require('crypto');
4-
var debug = require('debug')("qs:signature")
4+
var clone = require('clone');
5+
var debug = require('debug')("qs:signature");
6+
7+
exports.stringify = function(opts, urlOrPath) {
8+
if (!opts || !opts.signature || !urlOrPath)
9+
return qs.stringify(opts);
10+
11+
debug("signature base64 key", opts.signature);
12+
//in order to avoid messing with the key stored by reference, extend:
13+
var options = clone(opts);
514

6-
exports.stringify = function(options, urlOrPath) {
7-
if (!options || !options.signature || !urlOrPath)
8-
return qs.stringify(options);
915
debug("original url/path", urlOrPath);
1016

1117
var usablePrivateKey = new Buffer(websafe(options.signature), 'base64');

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
"author": "Florian Traverse",
1919
"license": "MIT",
2020
"dependencies": {
21+
"clone": "^0.1.18",
2122
"debug": "^2.1.0",
2223
"qs": "^2.3.3"
2324
},

0 commit comments

Comments
 (0)