koa 3.1.0 → 3.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/request.js +11 -1
- package/lib/response.js +4 -1
- package/package.json +2 -2
package/lib/request.js
CHANGED
|
@@ -256,7 +256,17 @@ module.exports = {
|
|
|
256
256
|
if (!host) host = this.get('Host')
|
|
257
257
|
}
|
|
258
258
|
if (!host) return ''
|
|
259
|
-
|
|
259
|
+
host = splitCommaSeparatedValues(host, 1)[0]
|
|
260
|
+
// Host header may contain userinfo (e.g., "user@host") which is invalid per RFC 7230.
|
|
261
|
+
// Use URL parser to correctly extract the host portion.
|
|
262
|
+
if (host.includes('@')) {
|
|
263
|
+
try {
|
|
264
|
+
host = new URL(`http://${host}`).host
|
|
265
|
+
} catch (e) {
|
|
266
|
+
return ''
|
|
267
|
+
}
|
|
268
|
+
}
|
|
269
|
+
return host
|
|
260
270
|
},
|
|
261
271
|
|
|
262
272
|
/**
|
package/lib/response.js
CHANGED
|
@@ -139,7 +139,10 @@ module.exports = {
|
|
|
139
139
|
const cleanupPreviousStream = () => {
|
|
140
140
|
if (original && isStream(original)) {
|
|
141
141
|
original.once('error', () => {})
|
|
142
|
-
destroy
|
|
142
|
+
// Only destroy if the new value is not a stream
|
|
143
|
+
if (!isStream(val)) {
|
|
144
|
+
destroy(original)
|
|
145
|
+
}
|
|
143
146
|
}
|
|
144
147
|
}
|
|
145
148
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "koa",
|
|
3
|
-
"version": "3.1.
|
|
3
|
+
"version": "3.1.2",
|
|
4
4
|
"description": "Koa web app framework",
|
|
5
5
|
"main": "lib/application.js",
|
|
6
6
|
"exports": {
|
|
@@ -37,7 +37,7 @@
|
|
|
37
37
|
"license": "MIT",
|
|
38
38
|
"dependencies": {
|
|
39
39
|
"accepts": "^1.3.8",
|
|
40
|
-
"content-disposition": "~0.
|
|
40
|
+
"content-disposition": "~1.0.1",
|
|
41
41
|
"content-type": "^1.0.5",
|
|
42
42
|
"cookies": "~0.9.1",
|
|
43
43
|
"delegates": "^1.0.0",
|