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