@nxtedition/lib 15.0.1 → 15.0.3
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/mime.js +3 -3
- package/package.json +1 -1
- package/undici/index.js +5 -1
package/mime.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
const mime = require('mime')
|
|
2
2
|
|
|
3
3
|
function lookup(name) {
|
|
4
|
-
if (
|
|
4
|
+
if (typeof name !== 'string' || name.length === 0) {
|
|
5
5
|
return null
|
|
6
6
|
}
|
|
7
7
|
if (/\.nut$/.test(name)) {
|
|
@@ -30,7 +30,7 @@ function lookup(name) {
|
|
|
30
30
|
}
|
|
31
31
|
|
|
32
32
|
function extension(type, name) {
|
|
33
|
-
if (
|
|
33
|
+
if (typeof type !== 'string' || type.length === 0) {
|
|
34
34
|
return null
|
|
35
35
|
}
|
|
36
36
|
if (/video\/(x-)?nut/.test(type)) {
|
|
@@ -51,7 +51,7 @@ function extension(type, name) {
|
|
|
51
51
|
|
|
52
52
|
const extension = mime.getExtension(type) || (type || '').split('/').pop()
|
|
53
53
|
|
|
54
|
-
if (extension === 'qt' && name
|
|
54
|
+
if (extension === 'qt' && typeof name === 'string' && name.endsWith('mov')) {
|
|
55
55
|
return 'mov'
|
|
56
56
|
}
|
|
57
57
|
|
package/package.json
CHANGED
package/undici/index.js
CHANGED
|
@@ -6,12 +6,13 @@ const stream = require('stream')
|
|
|
6
6
|
const { parseHeaders } = require('../http')
|
|
7
7
|
|
|
8
8
|
class Readable extends stream.Readable {
|
|
9
|
-
constructor({ statusCode, statusMessage, headers, ...opts }) {
|
|
9
|
+
constructor({ statusCode, statusMessage, headers, size, ...opts }) {
|
|
10
10
|
super(opts)
|
|
11
11
|
this.statusCode = statusCode
|
|
12
12
|
this.statusMessage = statusMessage
|
|
13
13
|
this.headers = headers
|
|
14
14
|
this.body = this
|
|
15
|
+
this.size = size
|
|
15
16
|
}
|
|
16
17
|
|
|
17
18
|
async text() {
|
|
@@ -156,12 +157,15 @@ async function request(urlOrOpts, opts = {}) {
|
|
|
156
157
|
} else {
|
|
157
158
|
assert(statusCode >= 200)
|
|
158
159
|
|
|
160
|
+
const contentLength = Number(headers['content-length'] ?? headers['Content-Length'])
|
|
161
|
+
|
|
159
162
|
this.body = new Readable({
|
|
160
163
|
read: resume,
|
|
161
164
|
highWaterMark: 128 * 1024,
|
|
162
165
|
statusCode,
|
|
163
166
|
statusMessage,
|
|
164
167
|
headers,
|
|
168
|
+
size: Number.isFinite(contentLength) ? contentLength : null,
|
|
165
169
|
})
|
|
166
170
|
|
|
167
171
|
this.resolve(this.body)
|