koa 0.21.1 → 0.21.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 CHANGED
@@ -211,7 +211,7 @@ module.exports = {
211
211
  var host = proxy && this.get('X-Forwarded-Host');
212
212
  host = host || this.get('Host');
213
213
  if (!host) return '';
214
- return host.split(/\s*,\s*/)[0];
214
+ return splitCommaSeparatedValues(host, 1)[0];
215
215
  },
216
216
 
217
217
  /**
@@ -334,7 +334,7 @@ module.exports = {
334
334
  if (this.socket.encrypted) return 'https';
335
335
  if (!proxy) return 'http';
336
336
  var proto = this.get('X-Forwarded-Proto') || 'http';
337
- return proto.split(/\s*,\s*/)[0];
337
+ return splitCommaSeparatedValues(proto, 1)[0];
338
338
  },
339
339
 
340
340
  /**
@@ -379,7 +379,7 @@ module.exports = {
379
379
  var proxy = this.app.proxy;
380
380
  var val = this.get('X-Forwarded-For');
381
381
  return proxy && val
382
- ? val.split(/\s*,\s*/)
382
+ ? splitCommaSeparatedValues(val)
383
383
  : [];
384
384
  },
385
385
 
@@ -608,3 +608,15 @@ module.exports = {
608
608
  };
609
609
  }
610
610
  };
611
+
612
+ /**
613
+ * Split a comma-separated value string into an array of values, with an optional limit.
614
+ * All the values are trimmed of whitespace.
615
+ *
616
+ * @param {string} value - The comma-separated value string to split.
617
+ * @param {number} [limit] - The maximum number of values to return.
618
+ * @returns {string[]} An array of values from the comma-separated string.
619
+ */
620
+ function splitCommaSeparatedValues(value, limit) {
621
+ return value.split(',', limit).map(v => v.trim());
622
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "koa",
3
- "version": "0.21.1",
3
+ "version": "0.21.2",
4
4
  "description": "Koa web app framework",
5
5
  "main": "lib/application.js",
6
6
  "scripts": {
package/History.md DELETED
@@ -1,267 +0,0 @@
1
-
2
- 0.21.1 / 2018-09-12
3
- ==================
4
-
5
- * deps: pin debug@2 (#1246)
6
-
7
- 0.21.0 / 2015-05-23
8
- ==================
9
-
10
- * empty `request.query` objects are now always the same instance
11
- * bump `fresh@0.3.0`
12
-
13
- 0.20.0 / 2015-04-30
14
- ==================
15
-
16
- Breaking change if you're using `this.get('ua') === undefined` etc.
17
- For more details please checkout [#438](https://github.com/koajs/koa/pull/438).
18
-
19
- * make sure helpers return strict string
20
- * feat: alias response.headers to response.header
21
-
22
- 0.19.1 / 2015-04-14
23
- ==================
24
-
25
- * non-error thrown, fixed #432
26
-
27
- 0.19.0 / 2015-04-05
28
- ==================
29
-
30
- * `req.host` and `req.hostname` now always return a string (semi-breaking change)
31
- * improved test coverage
32
-
33
- 0.18.1 / 2015-03-01
34
- ==================
35
-
36
- * move babel to `devDependencies`
37
-
38
- 0.18.0 / 2015-02-14
39
- ==================
40
-
41
- * experimental es7 async function support via `app.experimental = true`
42
- * use `content-type` instead of `media-typer`
43
-
44
- 0.17.0 / 2015-02-05
45
- ==================
46
-
47
- Breaking change if you're using an old version of node v0.11!
48
- Otherwise, you should have no trouble upgrading.
49
-
50
- * official iojs support
51
- * drop support for node.js `>= 0.11.0 < 0.11.16`
52
- * use `Object.setPrototypeOf()` instead of `__proto__`
53
- * update dependencies
54
-
55
- 0.16.0 / 2015-01-27
56
- ==================
57
-
58
- * add `res.append()`
59
- * fix path usage for node@0.11.15
60
-
61
- 0.15.0 / 2015-01-18
62
- ==================
63
-
64
- * add `this.href`
65
-
66
- 0.14.0 / 2014-12-15
67
- ==================
68
-
69
- * remove `x-powered-by` response header
70
- * fix the content type on plain-text redirects
71
- * add ctx.state
72
- * bump `co@4`
73
- * bump dependencies
74
-
75
- 0.13.0 / 2014-10-17
76
- ==================
77
-
78
- * add this.message
79
- * custom status support via `statuses`
80
-
81
- 0.12.2 / 2014-09-28
82
- ==================
83
-
84
- * use wider semver ranges for dependencies koa maintainers also maintain
85
-
86
- 0.12.1 / 2014-09-21
87
- ==================
88
-
89
- * bump content-disposition
90
- * bump statuses
91
-
92
- 0.12.0 / 2014-09-20
93
- ==================
94
-
95
- * add this.assert()
96
- * use content-disposition
97
-
98
- 0.11.0 / 2014-09-08
99
- ==================
100
-
101
- * fix app.use() assertion #337
102
- * bump a lot of dependencies
103
-
104
- 0.10.0 / 2014-08-12
105
- ==================
106
-
107
- * add `ctx.throw(err, object)` support
108
- * add `ctx.throw(err, status, object)` support
109
-
110
- 0.9.0 / 2014-08-07
111
- ==================
112
-
113
- * add: do not set `err.expose` to true when err.status not a valid http status code
114
- * add: alias `request.headers` as `request.header`
115
- * add context.inspect(), cleanup app.inspect()
116
- * update cookies
117
- * fix `err.status` invalid lead to uncaughtException
118
- * fix middleware gif, close #322
119
-
120
- 0.8.2 / 2014-07-27
121
- ==================
122
-
123
- * bump co
124
- * bump parseurl
125
-
126
- 0.8.1 / 2014-06-24
127
- ==================
128
-
129
- * bump type-is
130
-
131
- 0.8.0 / 2014-06-13
132
- ==================
133
-
134
- * add `this.response.is()``
135
- * remove `.status=string` and `res.statusString` #298
136
-
137
- 0.7.0 / 2014-06-07
138
- ==================
139
-
140
- * add `this.lastModified` and `this.etag` as both getters and setters for ubiquity #292.
141
- See koajs/koa@4065bf7 for an explanation.
142
- * refactor `this.response.vary()` to use [vary](https://github.com/expressjs/vary) #291
143
- * remove `this.response.append()` #291
144
-
145
- 0.6.3 / 2014-06-06
146
- ==================
147
-
148
- * fix res.type= when the extension is unknown
149
- * assert when non-error is passed to app.onerror #287
150
- * bump finished
151
-
152
- 0.6.2 / 2014-06-03
153
- ==================
154
-
155
- * switch from set-type to mime-types
156
-
157
- 0.6.1 / 2014-05-11
158
- ==================
159
-
160
- * bump type-is
161
- * bump koa-compose
162
-
163
- 0.6.0 / 2014-05-01
164
- ==================
165
-
166
- * add nicer error formatting
167
- * add: assert object type in ctx.onerror
168
- * change .status default to 404. Closes #263
169
- * remove .outputErrors, suppress output when handled by the dev. Closes #272
170
- * fix content-length when body is re-assigned. Closes #267
171
-
172
- 0.5.5 / 2014-04-14
173
- ==================
174
-
175
- * fix length when .body is missing
176
- * fix: make sure all intermediate stream bodies will be destroyed
177
-
178
- 0.5.4 / 2014-04-12
179
- ==================
180
-
181
- * fix header stripping in a few cases
182
-
183
- 0.5.3 / 2014-04-09
184
- ==================
185
-
186
- * change res.type= to always default charset. Closes #252
187
- * remove ctx.inspect() implementation. Closes #164
188
-
189
- 0.5.2 / 2014-03-23
190
- ==================
191
-
192
- * fix: inspection of `app` and `app.toJSON()`
193
- * fix: let `this.throw`n errors provide their own status
194
- * fix: overwriting of `content-type` w/ `HEAD` requests
195
- * refactor: use statuses
196
- * refactor: use escape-html
197
- * bump dev deps
198
-
199
- 0.5.1 / 2014-03-06
200
- ==================
201
-
202
- * add request.hostname(getter). Closes #224
203
- * remove response.charset and ctx.charset (too confusing in relation to ctx.type) [breaking change]
204
- * fix a debug() name
205
-
206
- 0.5.0 / 2014-02-19
207
- ==================
208
-
209
- * add context.charset
210
- * add context.charset=
211
- * add request.charset
212
- * add response.charset
213
- * add response.charset=
214
- * fix response.body= html content sniffing
215
- * change ctx.length and ctx.type to always delegate to response object [breaking change]
216
-
217
- 0.4.0 / 2014-02-11
218
- ==================
219
-
220
- * remove app.jsonSpaces settings - moved to [koa-json](https://github.com/koajs/json)
221
- * add this.response=false to bypass koa's response handling
222
- * fix response handling after body has been sent
223
- * changed ctx.throw() to no longer .expose 5xx errors
224
- * remove app.keys getter/setter, update cookies, and remove keygrip deps
225
- * update fresh
226
- * update koa-compose
227
-
228
- 0.3.0 / 2014-01-17
229
- ==================
230
-
231
- * add ctx.host= delegate
232
- * add req.host=
233
- * add: context.throw supports Error instances
234
- * update co
235
- * update cookies
236
-
237
- 0.2.1 / 2013-12-30
238
- ==================
239
-
240
- * add better 404 handling
241
- * add check for fn._name in debug() output
242
- * add explicit .toJSON() calls to ctx.toJSON()
243
-
244
- 0.2.0 / 2013-12-28
245
- ==================
246
-
247
- * add support for .throw(status, msg). Closes #130
248
- * add GeneratorFunction assertion for app.use(). Closes #120
249
- * refactor: move `.is()` to `type-is`
250
- * refactor: move content negotiation to "accepts"
251
- * refactor: allow any streams with .pipe method
252
- * remove `next` in callback for now
253
-
254
- 0.1.2 / 2013-12-21
255
- ==================
256
-
257
- * update co, koa-compose, keygrip
258
- * use on-socket-error
259
- * add throw(status, msg) support
260
- * assert middleware is GeneratorFunction
261
- * ducktype stream checks
262
- * remove `next` is `app.callback()`
263
-
264
- 0.1.1 / 2013-12-19
265
- ==================
266
-
267
- * fix: cleanup socker error handler on response