@jnode/server 2.2.0 → 2.2.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.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/src/handlers.js +5 -6
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jnode/server",
3
- "version": "2.2.0",
3
+ "version": "2.2.1",
4
4
  "description": "Simple web server package for Node.js.",
5
5
  "main": "src/index.js",
6
6
  "scripts": {
package/src/handlers.js CHANGED
@@ -220,18 +220,17 @@ class RedirectHandler {
220
220
 
221
221
  // prebuild headers
222
222
  this._statusCode = this.options.statusCode ?? 307;
223
- this._headers = {
223
+ }
224
+
225
+ handle(ctx, env) {
226
+ ctx.res.writeHead(this._statusCode, {
224
227
  'Location': this.options.base ?
225
228
  this.options.base +
226
229
  (this.options.base.endsWith('/') ? '' : '/') +
227
230
  env.path.slice(env.pathPointer).map(encodeURIComponent).join('/') :
228
231
  this.location,
229
232
  ...this.options.headers
230
- };
231
- }
232
-
233
- handle(ctx, env) {
234
- ctx.res.writeHead(this._statusCode, this._headers);
233
+ });
235
234
  ctx.res.end();
236
235
  }
237
236
  }