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