Skip to content

Commit

Permalink
feat: added fast-safe-stringify instead of JSON.stringify (closes #1464)
Browse files Browse the repository at this point in the history
  • Loading branch information
niftylettuce committed Jun 14, 2019
1 parent 6dc3eaa commit 2e5d6fd
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 3 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
"component-emitter": "^1.3.0",
"cookiejar": "^2.1.2",
"debug": "^4.1.1",
"fast-safe-stringify": "^2.0.6",
"form-data": "^2.3.3",
"formidable": "^1.2.1",
"methods": "^1.1.2",
Expand Down
3 changes: 2 additions & 1 deletion src/client.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ if (typeof window !== 'undefined') {
}

const Emitter = require('component-emitter');
const safeStringify = require('fast-safe-stringify');
const RequestBase = require('./request-base');
const isObject = require('./is-object');
const ResponseBase = require('./response-base');
Expand Down Expand Up @@ -213,7 +214,7 @@ request.types = {

request.serialize = {
'application/x-www-form-urlencoded': serialize,
'application/json': JSON.stringify
'application/json': safeStringify
};

/**
Expand Down
3 changes: 2 additions & 1 deletion src/node/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ const formidable = require('formidable');
const debug = require('debug')('superagent');
const CookieJar = require('cookiejar');
const semver = require('semver');
const safeStringify = require('fast-safe-stringify');

const utils = require('../utils');
const pkg = require('../../package.json');
Expand Down Expand Up @@ -102,7 +103,7 @@ exports.protocols = {

exports.serialize = {
'application/x-www-form-urlencoded': qs.stringify,
'application/json': JSON.stringify
'application/json': safeStringify
};

/**
Expand Down
7 changes: 6 additions & 1 deletion yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3966,6 +3966,11 @@ fast-levenshtein@~2.0.4:
resolved "https://registry.yarnpkg.com/fast-levenshtein/-/fast-levenshtein-2.0.6.tgz#3d8a5c66883a16a30ca8643e851f19baa7797917"
integrity sha1-PYpcZog6FqMMqGQ+hR8Zuqd5eRc=

fast-safe-stringify@^2.0.6:
version "2.0.6"
resolved "https://registry.yarnpkg.com/fast-safe-stringify/-/fast-safe-stringify-2.0.6.tgz#04b26106cc56681f51a044cfc0d76cf0008ac2c2"
integrity sha512-q8BZ89jjc+mz08rSxROs8VsrBBcn1SIw1kq9NjolL509tkABRk9io01RAjSaEv1Xb2uFLt8VtRiZbGp5H8iDtg==

fault@^1.0.0, fault@^1.0.2:
version "1.0.3"
resolved "https://registry.yarnpkg.com/fault/-/fault-1.0.3.tgz#4da88cf979b6b792b4e13c7ec836767725170b7e"
Expand Down Expand Up @@ -8117,7 +8122,7 @@ remark-heading-gap@^3.0.0:
resolved "https://registry.yarnpkg.com/remark-heading-gap/-/remark-heading-gap-3.1.0.tgz#6a1851b4226fa82441ae1365bbd599d34b12d812"
integrity sha512-KxH9CTgfDnVTZVMMLJRw73zxZSWGX+p6x/trG7ed2UsEYqMRr8Dqtu/SXp2vD1ZZhPM8CpS7SjS+qjmiaRFotw==

"remark-license@github:niftylettuce/remark-license":
remark-license@niftylettuce/remark-license:
version "4.0.1"
resolved "https://codeload.github.com/niftylettuce/remark-license/tar.gz/17ecb8f64f8f6082414d14f9267a12764e6ddbfb"
dependencies:
Expand Down

0 comments on commit 2e5d6fd

Please sign in to comment.