Skip to content

Commit 450f7b2

Browse files
authoredApr 23, 2024··
Merge branch 'master' into patch-2
2 parents a5c39b2 + ea633d7 commit 450f7b2

File tree

9 files changed

+52
-48
lines changed

9 files changed

+52
-48
lines changed
 

‎.github/workflows/ci.yml

+10-22
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,6 @@ jobs:
1414
strategy:
1515
matrix:
1616
include:
17-
- node-version: 10.x
18-
test-on-old-node: 1
19-
- node-version: 12.x
20-
test-on-old-node: 1
21-
# test-on-brower: 1
2217
- node-version: 14.x
2318
- node-version: 16.x
2419
- node-version: 18.x
@@ -29,25 +24,18 @@ jobs:
2924
uses: actions/setup-node@v3
3025
with:
3126
node-version: ${{ matrix.node-version }}
32-
- name: Cache node modules
33-
uses: actions/cache@v3
34-
env:
35-
cache-name: cache-node-modules
36-
with:
37-
# npm cache files are stored in `~/.npm` on Linux/macOS
38-
path: ~/.npm
39-
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/yarn.lock') }}
40-
- name: Install Dependencies On Old Node ${{ matrix.node-version }}
41-
if: ${{ matrix.test-on-old-node == '1' }}
42-
run: node ci/remove-deps-4-old-node.js && yarn install --ignore-scripts
43-
- name: Install Dependencies On Node ${{ matrix.node-version }}
44-
if: ${{ matrix.test-on-old-node != '1' }}
45-
run: yarn install
27+
# - name: Cache node modules
28+
# uses: actions/cache@v3
29+
# env:
30+
# cache-name: cache-node-modules
31+
# with:
32+
# # npm cache files are stored in `~/.npm` on Linux/macOS
33+
# path: ~/.npm
34+
# key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/yarn.lock') }}
35+
- name: Install dependencies
36+
run: npm install
4637
- name: Build
4738
run: npm run build
48-
- name: Build On Old Node
49-
if: ${{ matrix.test-on-old-node == '1' }}
50-
run: npm run build:test
5139
- name: Test On Node ${{ matrix.node-version }}
5240
env:
5341
BROWSER: ${{ matrix.test-on-brower }}

‎.lib.babelrc

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"presets": [
33
["@babel/env", {
44
"targets": {
5-
"node": "6.4.0",
5+
"node": "14.18.0",
66
"browsers": [ "defaults, not ie 11" ]
77
}
88
}]

‎.test.babelrc

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"presets": [
33
["@babel/env", {
44
"targets": {
5-
"node": "6.4.0",
5+
"node": "14.18.0",
66
"browsers": [ "defaults, not ie 11" ]
77
}
88
}]

‎.travis.yml

-9
Original file line numberDiff line numberDiff line change
@@ -4,18 +4,9 @@ node_js:
44
- '18'
55
- '16'
66
- '14'
7-
- '12'
87
after_success: npm run coverage
98

109
env:
1110
global:
1211
- SAUCE_USERNAME='shtylman-superagent'
1312
- SAUCE_ACCESS_KEY='39a45464-cb1d-4b8d-aa1f-83c7c04fa673'
14-
15-
matrix:
16-
include:
17-
- node_js: "10"
18-
env: BROWSER=1
19-
include:
20-
- node_js: "12"
21-
env: HTTP2_TEST=1

‎README.md

+5-4
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ Browser-ready versions of this module are available via [jsdelivr][], [unpkg][],
8383
This is the solution for you if you're just using `<script>` tags everywhere!
8484

8585
```html
86-
<script src="https://polyfill.io/v3/polyfill.min.js?features=WeakRef,BigInt"></script>
86+
<script src="https://cdnjs.cloudflare.com/polyfill/v3/polyfill.min.js?features=WeakRef,BigInt"></script>
8787
<script src="https://cdn.jsdelivr.net/npm/superagent"></script>
8888
<!-- if you wish to use unpkg.com instead: -->
8989
<!-- <script src="https://unpkg.com/superagent"></script> -->
@@ -112,7 +112,7 @@ If you are using [browserify][], [webpack][], [rollup][], or another bundler, th
112112

113113
## Supported Platforms
114114

115-
* Node: v6.x+
115+
* Node: v14.18.0+
116116
* Browsers (see [.browserslistrc](.browserslistrc)):
117117

118118
```sh
@@ -155,10 +155,10 @@ If you are using [browserify][], [webpack][], [rollup][], or another bundler, th
155155

156156
### Required Browser Features
157157

158-
We recommend using <https://polyfill.io> (specifically with the bundle mentioned in [VanillaJS](#vanillajs) above):
158+
We recommend using <https://cdnjs.cloudflare.com/polyfill/> (specifically with the bundle mentioned in [VanillaJS](#vanillajs) above):
159159

160160
```html
161-
<script src="https://polyfill.io/v3/polyfill.min.js?features=WeakRef,BigInt"></script>
161+
<script src="https://cdnjs.cloudflare.com/polyfill/v3/polyfill.min.js?features=WeakRef,BigInt"></script>
162162
```
163163

164164
* WeakRef is not supported in Opera 85, iOS Safari 12.2-12.5
@@ -202,6 +202,7 @@ Existing plugins:
202202
* [superagent-declare](https://github.com/damoclark/superagent-declare) - A simple [declarative](https://en.wikipedia.org/wiki/Declarative_programming) API for SuperAgent
203203
* [superagent-node-http-timings](https://github.com/webuniverseio/superagent-node-http-timings) - measure http timings in node.js
204204
* [superagent-cheerio](https://github.com/mmmmmrob/superagent-cheerio) - add [cheerio](https://www.npmjs.com/package/cheerio) to your response content automatically. Adds `res.$` for HTML and XML response bodies.
205+
* [@certible/superagent-aws-sign](https://github.com/certible/superagent-aws-sign) - Sign AWS endpoint requests, it uses the aws4 to authenticate the SuperAgent requests
205206

206207
Please prefix your plugin with `superagent-*` so that it can easily be found by others.
207208

‎docs/index.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -868,10 +868,10 @@ Libraries like [co](https://github.com/tj/co) or a web framework like [koa](http
868868

869869
Note that SuperAgent expects the global `Promise` object to be present. You'll need to use v7 and a polyfill to use promises in Internet Explorer or Node.js 0.10.
870870

871-
We have dropped support in v8 for IE. You must add a polyfill for WeakRef and BigInt if you wish to support Opera 85, iOS Safari 12.2-12.5, for example using <https://polyfill.io>:
871+
We have dropped support in v8 for IE. You must add a polyfill for WeakRef and BigInt if you wish to support Opera 85, iOS Safari 12.2-12.5, for example using <https://cdnjs.cloudflare.com/polyfill/>:
872872

873873
```html
874-
<script src="https://polyfill.io/v3/polyfill.min.js?features=WeakRef,BigInt"></script>
874+
<script src="https://cdnjs.cloudflare.com/polyfill/v3/polyfill.min.js?features=WeakRef,BigInt"></script>
875875
```
876876

877877
## Browser and node versions

‎index.html

+2-2
Original file line numberDiff line numberDiff line change
@@ -623,8 +623,8 @@ <h2 id="promise-and-generator-support">Promise and Generator support</h2>
623623
const res = yield req;
624624
</code></pre>
625625
<p>Note that SuperAgent expects the global <code>Promise</code> object to be present. You&#39;ll need to use v7 and a polyfill to use promises in Internet Explorer or Node.js 0.10.</p>
626-
<p>We have dropped support in v8 for IE. You must add a polyfill for WeakRef and BigInt if you wish to support Opera 85, iOS Safari 12.2-12.5, for example using <a href="https://polyfill.io">https://polyfill.io</a>:</p>
627-
<pre><code class="language-html">&lt;script src=&quot;https://polyfill.io/v3/polyfill.min.js?features=WeakRef,BigInt&quot;&gt;&lt;/script&gt;
626+
<p>We have dropped support in v8 for IE. You must add a polyfill for WeakRef and BigInt if you wish to support Opera 85, iOS Safari 12.2-12.5, for example using <a href="https://cdnjs.cloudflare.com/polyfill/">https://cdnjs.cloudflare.com/polyfill/</a>:</p>
627+
<pre><code class="language-html">&lt;script src=&quot;https://cdnjs.cloudflare.com/polyfill/v3/polyfill.min.js?features=WeakRef,BigInt&quot;&gt;&lt;/script&gt;
628628
</code></pre>
629629
<h2 id="browser-and-node-versions">Browser and node versions</h2>
630630
<p>SuperAgent has two implementations: one for web browsers (using XHR) and one for Node.JS (using core http module). By default Browserify and WebPack will pick the browser version.</p>

‎package.json

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "superagent",
33
"description": "elegant & feature rich browser / node HTTP with a fluent API",
4-
"version": "8.1.2",
4+
"version": "9.0.0",
55
"author": "TJ Holowaychuk <tj@vision-media.ca>",
66
"browser": {
77
"./src/node/index.js": "./src/client.js",
@@ -24,7 +24,7 @@
2424
"debug": "^4.3.4",
2525
"fast-safe-stringify": "^2.1.1",
2626
"form-data": "^4.0.0",
27-
"formidable": "^2.1.2",
27+
"formidable": "^3.5.1",
2828
"methods": "^1.1.2",
2929
"mime": "2.6.0",
3030
"qs": "^6.11.0",
@@ -38,8 +38,8 @@
3838
"@babel/runtime": "^7.20.13",
3939
"@commitlint/cli": "17",
4040
"@commitlint/config-conventional": "17",
41-
"Base64": "^1.1.0",
4241
"babelify": "^10.0.0",
42+
"Base64": "^1.1.0",
4343
"basic-auth-connect": "^1.0.0",
4444
"body-parser": "^1.20.1",
4545
"browserify": "^17.0.0",
@@ -69,7 +69,7 @@
6969
"zuul": "^3.12.0"
7070
},
7171
"engines": {
72-
"node": ">=6.4.0 <13 || >=14"
72+
"node": ">=14.18.0"
7373
},
7474
"files": [
7575
"dist/*.js",

‎src/node/index.js

+27-3
Original file line numberDiff line numberDiff line change
@@ -469,7 +469,6 @@ Request.prototype._pipeContinue = function (stream, options) {
469469
res.pipe(stream, options);
470470
res.once('end', () => this.emit('end'));
471471
}
472-
473472
});
474473
return stream;
475474
};
@@ -1093,7 +1092,7 @@ Request.prototype._end = function () {
10931092
parser = exports.parse.image; // It's actually a generic Buffer
10941093
buffer = true;
10951094
} else if (multipart) {
1096-
const form = formidable();
1095+
const form = formidable.formidable();
10971096
parser = form.parse.bind(form);
10981097
buffer = true;
10991098
} else if (isBinary(mime)) {
@@ -1125,7 +1124,7 @@ Request.prototype._end = function () {
11251124
let parserHandlesEnd = false;
11261125
if (buffer) {
11271126
// Protectiona against zip bombs and other nuisance
1128-
let responseBytesLeft = this._maxResponseSize || 200_000_000;
1127+
let responseBytesLeft = this._maxResponseSize || 200000000;
11291128
res.on('data', (buf) => {
11301129
responseBytesLeft -= buf.byteLength || buf.length > 0 ? buf.length : 0;
11311130
if (responseBytesLeft < 0) {
@@ -1162,6 +1161,31 @@ Request.prototype._end = function () {
11621161
}
11631162

11641163
if (parserHandlesEnd) {
1164+
if (multipart) {
1165+
// formidable v3 always returns an array with the value in it
1166+
// so we need to flatten it
1167+
if (object) {
1168+
for (const key in object) {
1169+
const value = object[key];
1170+
if (Array.isArray(value) && value.length === 1) {
1171+
object[key] = value[0];
1172+
} else {
1173+
object[key] = value;
1174+
}
1175+
}
1176+
}
1177+
1178+
if (files) {
1179+
for (const key in files) {
1180+
const value = files[key];
1181+
if (Array.isArray(value) && value.length === 1) {
1182+
files[key] = value[0];
1183+
} else {
1184+
files[key] = value;
1185+
}
1186+
}
1187+
}
1188+
}
11651189
this.emit('end');
11661190
this.callback(null, this._emitResponse(object, files));
11671191
}

0 commit comments

Comments
 (0)
Please sign in to comment.