koa 1.7.0 → 1.7.1

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 CHANGED
@@ -230,7 +230,7 @@ module.exports = {
230
230
  var host = proxy && this.get('X-Forwarded-Host');
231
231
  host = host || this.get('Host');
232
232
  if (!host) return '';
233
- return host.split(/\s*,\s*/)[0];
233
+ return splitCommaSeparatedValues(host, 1)[0];
234
234
  },
235
235
 
236
236
  /**
@@ -358,7 +358,7 @@ module.exports = {
358
358
  if (this.socket.encrypted) return 'https';
359
359
  if (!proxy) return 'http';
360
360
  var proto = this.get('X-Forwarded-Proto') || 'http';
361
- return proto.split(/\s*,\s*/)[0];
361
+ return splitCommaSeparatedValues(proto, 1)[0];
362
362
  },
363
363
 
364
364
  /**
@@ -403,7 +403,7 @@ module.exports = {
403
403
  var proxy = this.app.proxy;
404
404
  var val = this.get('X-Forwarded-For');
405
405
  return proxy && val
406
- ? val.split(/\s*,\s*/)
406
+ ? splitCommaSeparatedValues(val)
407
407
  : [];
408
408
  },
409
409
 
@@ -634,3 +634,15 @@ module.exports = {
634
634
  };
635
635
  }
636
636
  };
637
+
638
+ /**
639
+ * Split a comma-separated value string into an array of values, with an optional limit.
640
+ * All the values are trimmed of whitespace.
641
+ *
642
+ * @param {string} value - The comma-separated value string to split.
643
+ * @param {number} [limit] - The maximum number of values to return.
644
+ * @returns {string[]} An array of values from the comma-separated string.
645
+ */
646
+ function splitCommaSeparatedValues(value, limit) {
647
+ return value.split(',', limit).map(v => v.trim());
648
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "koa",
3
- "version": "1.7.0",
3
+ "version": "1.7.1",
4
4
  "description": "Koa web app framework",
5
5
  "main": "lib/application.js",
6
6
  "scripts": {
package/History.md DELETED
@@ -1,382 +0,0 @@
1
-
2
- 1.7.0 / 2019-10-17
3
- ==================
4
-
5
- **features**
6
- * [[`db7f52d`](http://github.com/koajs/koa/commit/db7f52d05e1d3ca804494267239257e56d0fe2dc)] - feat: support sameSite=none cookies (bump cookies dependency) (#1390) (#1408) (Elias-Serneels <<elias.serneels@gmail.com>>)
7
-
8
- 1.6.2 / 2018-09-11
9
- ==================
10
-
11
- **fixes**
12
- * [[`fd3db0f`](http://github.com/koajs/koa/commit/fd3db0f3232f11efac96c3634671855164dc9b6c)] - fix: pin debug@2 avoid deprecated warnning (#1244) (fengmk2 <<fengmk2@gmail.com>>)
13
-
14
- **others**
15
- * [[`c67f543`](http://github.com/koajs/koa/commit/c67f543f754f49875d0857b100dec7438b03d6c5)] - test: make ci run faster (#1242) (fengmk2 <<fengmk2@gmail.com>>)
16
-
17
- 1.6.1 / 2018-09-11
18
- ==================
19
-
20
- **fixes**
21
- * [[`a92c83f`](http://github.com/koajs/koa/commit/a92c83f03c5a453868fd7781f65cb6a5896bcc2a)] - fix: pin debug@3 (#1241) (Yiyu He <<dead_horse@qq.com>>)
22
-
23
- 1.6.0 / 2018-02-12
24
- ==================
25
-
26
- * feat: ignore set/remove header/status when header sent (#1145)
27
-
28
- 1.5.1 / 2018-01-25
29
- ==================
30
-
31
- * fix: this.handleRequest replace app.handleRequest
32
-
33
- 1.5.0 / 2018-01-24
34
- ==================
35
-
36
- * expose the Application::handleRequest method
37
-
38
- 1.4.1 / 2017-10-09
39
- ==================
40
-
41
- * fix: upgrade fresh to the latest version (#1073)
42
-
43
- 1.4.0 / 2017-03-20
44
- ==================
45
-
46
- * deps: cookies@~0.7.0
47
-
48
- 1.3.0 / 2017-03-07
49
- ==================
50
-
51
- * added: node v7.7+ `res.getHeaderNames()` support #913
52
- * added: `err.headerSent` in error handling #923
53
-
54
- 1.2.5 / 2017-02-12
55
- ==================
56
-
57
- * Fix malformed content-type header causing exception on charset get (#897)
58
- * this.is() returns null when no body is passed (#850)
59
-
60
- 1.2.4 / 2016-09-07
61
- ==================
62
-
63
- * fix: should get subdomains from hostname instead (#809)
64
-
65
- 1.2.3 / 2016-09-07
66
- ==================
67
-
68
- * fix: subdomains should be [] if the host is an ip (#807)
69
-
70
- 1.2.2 / 2016-08-31
71
- ==================
72
-
73
- * fix: add named function for request and response handlers (#804)
74
- * Fixes typo in error handling section of API readme (#786)
75
-
76
- 1.2.1 / 2016-07-22
77
- ==================
78
-
79
- * fix(response): correct response.writable logic (#781)
80
- * fix some docs
81
-
82
- 1.2.0 / 2016-03-03
83
- ==================
84
-
85
- * add support for `err.headers` in `ctx.onerror()`
86
- - see: https://github.com/koajs/koa/pull/668
87
- - note: you should set these headers in your custom error handlers as well
88
- - docs: https://github.com/koajs/koa/blob/master/docs/error-handling.md
89
- * fix `cookies`' detection of http/https
90
- - see: https://github.com/koajs/koa/pull/614
91
- * deprecate `app.experimental = true`. Koa v2 does not use this signature.
92
- * add a code of conduct
93
- * test against the latest version of node
94
- * add a lot of docs
95
-
96
- 1.1.2 / 2015-11-05
97
- ==================
98
-
99
- * ensure parseurl always working as expected
100
- * fix Application.inspect() – missing .proxy value.
101
-
102
- 1.1.1 / 2015-10-22
103
- ==================
104
-
105
- * do not send a content-type when the type is unknown #536
106
-
107
- 1.1.0 / 2015-10-11
108
- ==================
109
-
110
- * add `app.silent=<Boolean>` to toggle error logging @tejasmanohar #486
111
- * add `ctx.origin` @chentsulin #480
112
- * various refactoring
113
- - add `use strict` everywhere
114
-
115
- 1.0.0 / 2015-08-22
116
- ==================
117
-
118
- * add `this.req` check for `querystring()`
119
- * don't log errors with `err.expose`
120
- * `koa` now follows semver!
121
-
122
- 0.21.0 / 2015-05-23
123
- ==================
124
-
125
- * empty `request.query` objects are now always the same instance
126
- * bump `fresh@0.3.0`
127
-
128
- 0.20.0 / 2015-04-30
129
- ==================
130
-
131
- Breaking change if you're using `this.get('ua') === undefined` etc.
132
- For more details please checkout [#438](https://github.com/koajs/koa/pull/438).
133
-
134
- * make sure helpers return strict string
135
- * feat: alias response.headers to response.header
136
-
137
- 0.19.1 / 2015-04-14
138
- ==================
139
-
140
- * non-error thrown, fixed #432
141
-
142
- 0.19.0 / 2015-04-05
143
- ==================
144
-
145
- * `req.host` and `req.hostname` now always return a string (semi-breaking change)
146
- * improved test coverage
147
-
148
- 0.18.1 / 2015-03-01
149
- ==================
150
-
151
- * move babel to `devDependencies`
152
-
153
- 0.18.0 / 2015-02-14
154
- ==================
155
-
156
- * experimental es7 async function support via `app.experimental = true`
157
- * use `content-type` instead of `media-typer`
158
-
159
- 0.17.0 / 2015-02-05
160
- ==================
161
-
162
- Breaking change if you're using an old version of node v0.11!
163
- Otherwise, you should have no trouble upgrading.
164
-
165
- * official iojs support
166
- * drop support for node.js `>= 0.11.0 < 0.11.16`
167
- * use `Object.setPrototypeOf()` instead of `__proto__`
168
- * update dependencies
169
-
170
- 0.16.0 / 2015-01-27
171
- ==================
172
-
173
- * add `res.append()`
174
- * fix path usage for node@0.11.15
175
-
176
- 0.15.0 / 2015-01-18
177
- ==================
178
-
179
- * add `this.href`
180
-
181
- 0.14.0 / 2014-12-15
182
- ==================
183
-
184
- * remove `x-powered-by` response header
185
- * fix the content type on plain-text redirects
186
- * add ctx.state
187
- * bump `co@4`
188
- * bump dependencies
189
-
190
- 0.13.0 / 2014-10-17
191
- ==================
192
-
193
- * add this.message
194
- * custom status support via `statuses`
195
-
196
- 0.12.2 / 2014-09-28
197
- ==================
198
-
199
- * use wider semver ranges for dependencies koa maintainers also maintain
200
-
201
- 0.12.1 / 2014-09-21
202
- ==================
203
-
204
- * bump content-disposition
205
- * bump statuses
206
-
207
- 0.12.0 / 2014-09-20
208
- ==================
209
-
210
- * add this.assert()
211
- * use content-disposition
212
-
213
- 0.11.0 / 2014-09-08
214
- ==================
215
-
216
- * fix app.use() assertion #337
217
- * bump a lot of dependencies
218
-
219
- 0.10.0 / 2014-08-12
220
- ==================
221
-
222
- * add `ctx.throw(err, object)` support
223
- * add `ctx.throw(err, status, object)` support
224
-
225
- 0.9.0 / 2014-08-07
226
- ==================
227
-
228
- * add: do not set `err.expose` to true when err.status not a valid http status code
229
- * add: alias `request.headers` as `request.header`
230
- * add context.inspect(), cleanup app.inspect()
231
- * update cookies
232
- * fix `err.status` invalid lead to uncaughtException
233
- * fix middleware gif, close #322
234
-
235
- 0.8.2 / 2014-07-27
236
- ==================
237
-
238
- * bump co
239
- * bump parseurl
240
-
241
- 0.8.1 / 2014-06-24
242
- ==================
243
-
244
- * bump type-is
245
-
246
- 0.8.0 / 2014-06-13
247
- ==================
248
-
249
- * add `this.response.is()``
250
- * remove `.status=string` and `res.statusString` #298
251
-
252
- 0.7.0 / 2014-06-07
253
- ==================
254
-
255
- * add `this.lastModified` and `this.etag` as both getters and setters for ubiquity #292.
256
- See koajs/koa@4065bf7 for an explanation.
257
- * refactor `this.response.vary()` to use [vary](https://github.com/expressjs/vary) #291
258
- * remove `this.response.append()` #291
259
-
260
- 0.6.3 / 2014-06-06
261
- ==================
262
-
263
- * fix res.type= when the extension is unknown
264
- * assert when non-error is passed to app.onerror #287
265
- * bump finished
266
-
267
- 0.6.2 / 2014-06-03
268
- ==================
269
-
270
- * switch from set-type to mime-types
271
-
272
- 0.6.1 / 2014-05-11
273
- ==================
274
-
275
- * bump type-is
276
- * bump koa-compose
277
-
278
- 0.6.0 / 2014-05-01
279
- ==================
280
-
281
- * add nicer error formatting
282
- * add: assert object type in ctx.onerror
283
- * change .status default to 404. Closes #263
284
- * remove .outputErrors, suppress output when handled by the dev. Closes #272
285
- * fix content-length when body is re-assigned. Closes #267
286
-
287
- 0.5.5 / 2014-04-14
288
- ==================
289
-
290
- * fix length when .body is missing
291
- * fix: make sure all intermediate stream bodies will be destroyed
292
-
293
- 0.5.4 / 2014-04-12
294
- ==================
295
-
296
- * fix header stripping in a few cases
297
-
298
- 0.5.3 / 2014-04-09
299
- ==================
300
-
301
- * change res.type= to always default charset. Closes #252
302
- * remove ctx.inspect() implementation. Closes #164
303
-
304
- 0.5.2 / 2014-03-23
305
- ==================
306
-
307
- * fix: inspection of `app` and `app.toJSON()`
308
- * fix: let `this.throw`n errors provide their own status
309
- * fix: overwriting of `content-type` w/ `HEAD` requests
310
- * refactor: use statuses
311
- * refactor: use escape-html
312
- * bump dev deps
313
-
314
- 0.5.1 / 2014-03-06
315
- ==================
316
-
317
- * add request.hostname(getter). Closes #224
318
- * remove response.charset and ctx.charset (too confusing in relation to ctx.type) [breaking change]
319
- * fix a debug() name
320
-
321
- 0.5.0 / 2014-02-19
322
- ==================
323
-
324
- * add context.charset
325
- * add context.charset=
326
- * add request.charset
327
- * add response.charset
328
- * add response.charset=
329
- * fix response.body= html content sniffing
330
- * change ctx.length and ctx.type to always delegate to response object [breaking change]
331
-
332
- 0.4.0 / 2014-02-11
333
- ==================
334
-
335
- * remove app.jsonSpaces settings - moved to [koa-json](https://github.com/koajs/json)
336
- * add this.response=false to bypass koa's response handling
337
- * fix response handling after body has been sent
338
- * changed ctx.throw() to no longer .expose 5xx errors
339
- * remove app.keys getter/setter, update cookies, and remove keygrip deps
340
- * update fresh
341
- * update koa-compose
342
-
343
- 0.3.0 / 2014-01-17
344
- ==================
345
-
346
- * add ctx.host= delegate
347
- * add req.host=
348
- * add: context.throw supports Error instances
349
- * update co
350
- * update cookies
351
-
352
- 0.2.1 / 2013-12-30
353
- ==================
354
-
355
- * add better 404 handling
356
- * add check for fn._name in debug() output
357
- * add explicit .toJSON() calls to ctx.toJSON()
358
-
359
- 0.2.0 / 2013-12-28
360
- ==================
361
-
362
- * add support for .throw(status, msg). Closes #130
363
- * add GeneratorFunction assertion for app.use(). Closes #120
364
- * refactor: move `.is()` to `type-is`
365
- * refactor: move content negotiation to "accepts"
366
- * refactor: allow any streams with .pipe method
367
- * remove `next` in callback for now
368
-
369
- 0.1.2 / 2013-12-21
370
- ==================
371
-
372
- * update co, koa-compose, keygrip
373
- * use on-socket-error
374
- * add throw(status, msg) support
375
- * assert middleware is GeneratorFunction
376
- * ducktype stream checks
377
- * remove `next` is `app.callback()`
378
-
379
- 0.1.1 / 2013-12-19
380
- ==================
381
-
382
- * fix: cleanup socker error handler on response