Skip to content

Commit

Permalink
chore: bump deps, including form-data (closes #1267)
Browse files Browse the repository at this point in the history
  • Loading branch information
niftylettuce committed Feb 15, 2021
1 parent e2987e3 commit 3c9c0f7
Show file tree
Hide file tree
Showing 10 changed files with 2,335 additions and 2,232 deletions.
3 changes: 2 additions & 1 deletion .dist.eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@
"Symbol",
"Object.getOwnPropertySymbols",
"Object.setPrototypeOf",
"Set"
"Set",
"Math.trunc"
]
}
}
14 changes: 8 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ Browser-ready versions of this module are available via [jsdelivr][], [unpkg][],
This is the solution for you if you're just using `<script>` tags everywhere!

```html
<script src="https://polyfill.io/v3/polyfill.min.js?features=Array.from,Promise,Symbol,Object.setPrototypeOf,Object.getOwnPropertySymbols,Set"></script>
<script src="https://polyfill.io/v3/polyfill.min.js?features=Array.from,Promise,Symbol,Object.setPrototypeOf,Object.getOwnPropertySymbols,Set,Math.trunc"></script>
<script src="https://cdn.jsdelivr.net/npm/superagent"></script>
<!-- if you wish to use unpkg.com instead: -->
<!-- <script src="https://unpkg.com/superagent"></script> -->
Expand Down Expand Up @@ -159,11 +159,11 @@ If you are using [browserify][], [webpack][], [rollup][], or another bundler, th
We recommend using <https://polyfill.io> (specifically with the bundle mentioned in [VanillaJS](#vanillajs) above):

```html
<script src="https://polyfill.io/v3/polyfill.min.js?features=Array.from,Promise,Symbol,Object.setPrototypeOf,Object.getOwnPropertySymbols,Set"></script>
<script src="https://polyfill.io/v3/polyfill.min.js?features=Array.from,Promise,Symbol,Object.setPrototypeOf,Object.getOwnPropertySymbols,Set,Math.trunc"></script>
```

* IE 9-10 requires a polyfill for `Promise`, `Array.from`, `Symbol`, `Object.getOwnPropertySymbols`, and `Object.setPrototypeOf`
* IE 9 requires a polyfill for `window.FormData` (we recommend [formdata-polyfill][]) and `Set`
* IE 9 requires a polyfill for `window.FormData` (we recommend [formdata-polyfill][]), `Set`, and `Math.trunc`


## Plugins
Expand Down Expand Up @@ -210,10 +210,12 @@ For SuperAgent extensions such as couchdb and oauth visit the [wiki](https://git

## Upgrading from previous versions

Please see [GitHub releases page](https://github.com/visionmedia/superagent/releases) for the current changelog.

Our breaking changes are mostly in rarely used functionality and from stricter error handling.

* [6.0 to 6.1](https://github.com/visionmedia/superagent/releases/tag/v6.1.0)
* Browser behaviour changed to match Node when serializing `application/x-www-form-urlencoded`, using `arrayFormat: 'indices'` semantics of `qs` library. (See: https://www.npmjs.com/package/qs#stringifying)
* Browser behaviour changed to match Node when serializing `application/x-www-form-urlencoded`, using `arrayFormat: 'indices'` semantics of `qs` library. (See: <https://www.npmjs.com/package/qs#stringifying>)
* [5.x to 6.x](https://github.com/visionmedia/superagent/releases/tag/v6.0.0):
* Retry behavior is still opt-in, however we now have a more fine-grained list of status codes and error codes that we retry against (see updated docs)
* A specific issue with Content-Type matching not being case-insensitive is fixed
Expand All @@ -231,7 +233,7 @@ Our breaking changes are mostly in rarely used functionality and from stricter e
* Ensure you're running Node 4 or later. We've dropped support for Node 0.x.
* Test code that calls `.send()` multiple times. Invalid calls to `.send()` will now throw instead of sending garbage.
* [1.x to 2.x](https://github.com/visionmedia/superagent/releases/tag/v2.0.0):
* If you use `.parse()` in the _browser_ version, rename it to `.serialize()`.
* If you use `.parse()` in the *browser* version, rename it to `.serialize()`.
* If you rely on `undefined` in query-string values being sent literally as the text "undefined", switch to checking for missing value instead. `?key=undefined` is now `?key` (without a value).
* If you use `.then()` in Internet Explorer, ensure that you have a polyfill that adds a global `Promise` object.
* 0.x to 1.x:
Expand All @@ -253,7 +255,7 @@ Our breaking changes are mostly in rarely used functionality and from stricter e
[MIT](LICENSE) © TJ Holowaychuk


##
##

[npm]: https://www.npmjs.com/

Expand Down
52 changes: 26 additions & 26 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,51 +25,51 @@
"dependencies": {
"component-emitter": "^1.3.0",
"cookiejar": "^2.1.2",
"debug": "^4.1.1",
"debug": "^4.3.1",
"fast-safe-stringify": "^2.0.7",
"form-data": "^3.0.0",
"form-data": "^4.0.0",
"formidable": "^1.2.2",
"methods": "^1.1.2",
"mime": "^2.4.6",
"qs": "^6.9.4",
"mime": "^2.5.0",
"qs": "^6.9.6",
"readable-stream": "^3.6.0",
"semver": "^7.3.2"
"semver": "^7.3.4"
},
"devDependencies": {
"@babel/cli": "^7.10.5",
"@babel/core": "^7.11.1",
"@babel/plugin-transform-runtime": "^7.11.0",
"@babel/preset-env": "^7.11.0",
"@commitlint/cli": "^9.1.1",
"@commitlint/config-conventional": "^9.1.1",
"@babel/cli": "^7.12.16",
"@babel/core": "^7.12.16",
"@babel/plugin-transform-runtime": "^7.12.15",
"@babel/preset-env": "^7.12.16",
"@commitlint/cli": "^11.0.0",
"@commitlint/config-conventional": "^11.0.0",
"Base64": "^1.1.0",
"babelify": "^10.0.0",
"basic-auth-connect": "^1.0.0",
"body-parser": "^1.19.0",
"browserify": "^16.5.2",
"codecov": "^3.7.2",
"browserify": "^17.0.0",
"codecov": "^3.8.1",
"cookie-parser": "^1.4.5",
"cross-env": "^7.0.2",
"eslint": "^7.6.0",
"eslint-config-xo-lass": "^1.0.3",
"eslint-plugin-compat": "^3.8.0",
"cross-env": "^7.0.3",
"eslint": "^7.20.0",
"eslint-config-xo-lass": "^1.0.5",
"eslint-plugin-compat": "^3.9.0",
"eslint-plugin-node": "^11.1.0",
"express": "^4.17.1",
"express-session": "^1.17.1",
"fixpack": "^3.0.6",
"husky": "^4.2.5",
"lint-staged": "^10.2.11",
"marked": "^1.1.1",
"fixpack": "^4.0.0",
"husky": "^5.0.9",
"lint-staged": "^10.5.4",
"marked": "^2.0.0",
"mocha": "3.5.3",
"multer": "^1.4.2",
"nyc": "^15.1.0",
"remark-cli": "^8.0.1",
"remark-preset-github": "^3.0.0",
"remark-cli": "^9.0.0",
"remark-preset-github": "^4.0.1",
"rimraf": "^3.0.2",
"should": "^13.2.3",
"should-http": "^0.1.1",
"tinyify": "^3.0.0",
"xo": "0.32.1",
"xo": "0.37.1",
"zuul": "^3.12.0"
},
"engines": {
Expand Down Expand Up @@ -167,14 +167,14 @@
"extends": [
"xo-lass"
],
"env": [
"envs": [
"node",
"browser"
],
"overrides": [
{
"files": "test/**/*.js",
"env": [
"envs": [
"mocha"
],
"rules": {
Expand Down
14 changes: 6 additions & 8 deletions src/node/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -1044,13 +1044,11 @@ Request.prototype._end = function () {
}

let parser = this._parser;
if (undefined === buffer) {
if (parser) {
console.warn(
"A custom superagent parser has been set, but buffering strategy for the parser hasn't been configured. Call `req.buffer(true or false)` or set `superagent.buffer[mime] = true or false`"
);
buffer = true;
}
if (undefined === buffer && parser) {
console.warn(
"A custom superagent parser has been set, but buffering strategy for the parser hasn't been configured. Call `req.buffer(true or false)` or set `superagent.buffer[mime] = true or false`"
);
buffer = true;
}

if (!parser) {
Expand Down Expand Up @@ -1093,7 +1091,7 @@ Request.prototype._end = function () {
// Protectiona against zip bombs and other nuisance
let responseBytesLeft = this._maxResponseSize || 200000000;
res.on('data', (buf) => {
responseBytesLeft -= buf.byteLength || buf.length;
responseBytesLeft -= buf.byteLength || buf.length > 0 ? buf.length : 0;
if (responseBytesLeft < 0) {
// This will propagate through error event
const err = new Error('Maximum response size reached');
Expand Down
2 changes: 1 addition & 1 deletion src/response-base.js
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ ResponseBase.prototype._setHeaderProperties = function (header) {
*/

ResponseBase.prototype._setStatusProperties = function (status) {
const type = (status / 100) | 0;
const type = Math.trunc(status / 100);

// status / class
this.statusCode = status;
Expand Down
76 changes: 36 additions & 40 deletions test/node/https.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,23 +49,21 @@ let testEndpoint;
describe('https', () => {
describe('certificate authority', () => {
before(function listen(done) {
if (process.env.HTTP2_TEST) {
server = http2.createSecureServer(
{
key,
cert
},
app
);
} else {
server = https.createServer(
{
key,
cert
},
app
);
}
server = process.env.HTTP2_TEST
? http2.createSecureServer(
{
key,
cert
},
app
)
: https.createServer(
{
key,
cert
},
app
);

server.listen(0, function listening() {
testEndpoint = `${base}:${server.address().port}`;
Expand Down Expand Up @@ -143,29 +141,27 @@ describe('https', () => {

describe.skip('client certificates', () => {
before(function listen(done) {
if (process.env.HTTP2_TEST) {
server = http2.createSecureServer(
{
ca,
key,
cert,
requestCert: true,
rejectUnauthorized: true
},
app
);
} else {
server = https.createServer(
{
ca,
key,
cert,
requestCert: true,
rejectUnauthorized: true
},
app
);
}
server = process.env.HTTP2_TEST
? http2.createSecureServer(
{
ca,
key,
cert,
requestCert: true,
rejectUnauthorized: true
},
app
)
: https.createServer(
{
ca,
key,
cert,
requestCert: true,
rejectUnauthorized: true
},
app
);

server.listen(0, function listening() {
testEndpoint = `${base}:${server.address().port}`;
Expand Down
8 changes: 3 additions & 5 deletions test/node/unix-sockets.js
Original file line number Diff line number Diff line change
Expand Up @@ -83,11 +83,9 @@ describe('[unix-sockets] https', () => {
fs.unlinkSync(httpsSockPath);
}

if (process.env.HTTP2_TEST) {
httpsServer = https.createSecureServer({ key, cert }, app);
} else {
httpsServer = https.createServer({ key, cert }, app);
}
httpsServer = process.env.HTTP2_TEST
? https.createSecureServer({ key, cert }, app)
: https.createServer({ key, cert }, app);

httpsServer.listen(httpsSockPath, done);
});
Expand Down
8 changes: 3 additions & 5 deletions test/support/express/responseDecorator.js
Original file line number Diff line number Diff line change
Expand Up @@ -171,10 +171,8 @@ function setMethods(res) {

// populate ETag
let etag;
if (generateETag && len !== undefined) {
if ((etag = etagFn(chunk, encoding))) {
this.set('ETag', etag);
}
if (generateETag && len !== undefined && (etag = etagFn(chunk, encoding))) {
this.set('ETag', etag);
}

// freshness
Expand Down Expand Up @@ -260,7 +258,7 @@ function setMethods(res) {
}

// jsonp
if (typeof callback === 'string' && callback.length !== 0) {
if (typeof callback === 'string' && callback.length > 0) {
this.set('X-Content-Type-Options', 'nosniff');
this.set('Content-Type', 'text/javascript');

Expand Down
4 changes: 2 additions & 2 deletions test/support/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,7 @@ app.get('/delay/slowbody/finish', (req, res) => {
});

app.get('/delay/:ms', (req, res) => {
const ms = ~~req.params.ms;
const ms = Math.trunc(req.params.ms);
setTimeout(() => {
res.sendStatus(200);
}, ms);
Expand Down Expand Up @@ -544,7 +544,7 @@ app.get('/delay/:ms/ok/:id', (req, res) => {
const { id } = req.params;
if (!called[id]) {
called[id] = true;
const ms = ~~req.params.ms;
const ms = Math.trunc(req.params.ms);
setTimeout(() => {
res.sendStatus(200);
}, ms);
Expand Down

0 comments on commit 3c9c0f7

Please sign in to comment.