@opra/http 1.25.1 → 1.25.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.
Files changed (2) hide show
  1. package/http-context.js +15 -4
  2. package/package.json +3 -3
package/http-context.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import typeIs from '@browsery/type-is';
2
- import { InternalServerError, NotAcceptableError, } from '@opra/common';
2
+ import { InternalServerError, MimeTypes, NotAcceptableError, } from '@opra/common';
3
3
  import { ExecutionContext, kAssetCache } from '@opra/core';
4
4
  import toml from 'toml';
5
5
  import yaml from 'yaml';
@@ -92,17 +92,28 @@ export class HttpContext extends ExecutionContext {
92
92
  if (encoding)
93
93
  this._body = this._body.toString(encoding);
94
94
  if (Buffer.isBuffer(this._body) &&
95
- request.is(['json', 'xml', 'txt', 'text', 'yaml', 'toml'])) {
95
+ request.is([
96
+ 'json',
97
+ 'xml',
98
+ 'txt',
99
+ 'text',
100
+ 'yaml',
101
+ 'toml',
102
+ MimeTypes.yaml2,
103
+ MimeTypes.toml2,
104
+ ])) {
96
105
  this._body = this._body.toString('utf-8');
97
106
  }
98
107
  // Transform text to Object if media is JSON
99
108
  if (typeof this._body === 'string' && request.is(['json']))
100
109
  this._body = JSON.parse(this._body);
101
110
  // Transform text to Object if media is YAML
102
- if (typeof this._body === 'string' && request.is(['yaml']))
111
+ if (typeof this._body === 'string' &&
112
+ request.is(['yaml', MimeTypes.yaml2]))
103
113
  this._body = yaml.parse(this._body);
104
114
  // Transform text to Object if media is YAML
105
- if (typeof this._body === 'string' && request.is(['toml']))
115
+ if (typeof this._body === 'string' &&
116
+ request.is(['toml', MimeTypes.toml2]))
106
117
  this._body = toml.parse(this._body);
107
118
  }
108
119
  if (mediaType) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@opra/http",
3
- "version": "1.25.1",
3
+ "version": "1.25.2",
4
4
  "description": "Opra Http Server Adapter",
5
5
  "author": "Panates",
6
6
  "license": "MIT",
@@ -38,8 +38,8 @@
38
38
  "yaml": "^2.8.3"
39
39
  },
40
40
  "peerDependencies": {
41
- "@opra/common": "^1.25.1",
42
- "@opra/core": "^1.25.1"
41
+ "@opra/common": "^1.25.2",
42
+ "@opra/core": "^1.25.2"
43
43
  },
44
44
  "optionalDependencies": {
45
45
  "express": "^4.0.0 || ^5.0.0",