koa-files 3.1.8 → 3.1.9
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/cjs/Service.cjs +1 -1
- package/cjs/index.cjs +1 -1
- package/cjs/utils/fs.cjs +1 -1
- package/cjs/utils/hash.cjs +2 -2
- package/cjs/utils/http.cjs +3 -3
- package/cjs/utils/path.cjs +1 -1
- package/cjs/utils/stream.cjs +1 -1
- package/esm/Service.js +1 -1
- package/esm/index.js +1 -1
- package/esm/utils/fs.js +1 -1
- package/esm/utils/hash.js +2 -2
- package/esm/utils/http.js +3 -3
- package/esm/utils/path.js +1 -1
- package/esm/utils/stream.js +1 -1
- package/package.json +1 -1
- package/types/utils/hash.d.ts +1 -1
package/cjs/Service.cjs
CHANGED
package/cjs/index.cjs
CHANGED
package/cjs/utils/fs.cjs
CHANGED
package/cjs/utils/hash.cjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @package koa-files
|
|
3
3
|
* @license MIT
|
|
4
|
-
* @version 3.1.
|
|
4
|
+
* @version 3.1.9
|
|
5
5
|
* @author nuintun <nuintun@qq.com>
|
|
6
6
|
* @description A static files serving middleware for koa.
|
|
7
7
|
* @see https://github.com/nuintun/koa-files#readme
|
|
@@ -32,7 +32,7 @@ const CHARS = [
|
|
|
32
32
|
* @description Generate a hash.
|
|
33
33
|
* @param length The length of hash.
|
|
34
34
|
*/
|
|
35
|
-
function generate(length
|
|
35
|
+
function generate(length) {
|
|
36
36
|
let hash = '';
|
|
37
37
|
const randomValues = crypto.getRandomValues(new Uint8Array(length));
|
|
38
38
|
// Create hash.
|
package/cjs/utils/http.cjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @package koa-files
|
|
3
3
|
* @license MIT
|
|
4
|
-
* @version 3.1.
|
|
4
|
+
* @version 3.1.9
|
|
5
5
|
* @author nuintun <nuintun@qq.com>
|
|
6
6
|
* @description A static files serving middleware for koa.
|
|
7
7
|
* @see https://github.com/nuintun/koa-files#readme
|
|
@@ -156,13 +156,13 @@ function parseRanges(context, stats) {
|
|
|
156
156
|
// Parsed entries.
|
|
157
157
|
const entries = parsed.entries();
|
|
158
158
|
// Range boundary.
|
|
159
|
-
const boundary =
|
|
159
|
+
const boundary = `${hash.generate(32)}`;
|
|
160
160
|
// Multipart Content-Type.
|
|
161
161
|
const contentType = `Content-Type: ${context.type}`;
|
|
162
162
|
// Range suffix.
|
|
163
163
|
const suffix = buffer.Buffer.from(`\r\n--${boundary}--\r\n`);
|
|
164
164
|
// Override Content-Type.
|
|
165
|
-
context.type = `multipart/byteranges; boundary
|
|
165
|
+
context.type = `multipart/byteranges; boundary="${boundary}"`;
|
|
166
166
|
// Map ranges.
|
|
167
167
|
for (const [index, { start, end }] of entries) {
|
|
168
168
|
const length = end - start + 1;
|
package/cjs/utils/path.cjs
CHANGED
package/cjs/utils/stream.cjs
CHANGED
package/esm/Service.js
CHANGED
package/esm/index.js
CHANGED
package/esm/utils/fs.js
CHANGED
package/esm/utils/hash.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @package koa-files
|
|
3
3
|
* @license MIT
|
|
4
|
-
* @version 3.1.
|
|
4
|
+
* @version 3.1.9
|
|
5
5
|
* @author nuintun <nuintun@qq.com>
|
|
6
6
|
* @description A static files serving middleware for koa.
|
|
7
7
|
* @see https://github.com/nuintun/koa-files#readme
|
|
@@ -30,7 +30,7 @@ const CHARS = [
|
|
|
30
30
|
* @description Generate a hash.
|
|
31
31
|
* @param length The length of hash.
|
|
32
32
|
*/
|
|
33
|
-
function generate(length
|
|
33
|
+
function generate(length) {
|
|
34
34
|
let hash = '';
|
|
35
35
|
const randomValues = getRandomValues(new Uint8Array(length));
|
|
36
36
|
// Create hash.
|
package/esm/utils/http.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @package koa-files
|
|
3
3
|
* @license MIT
|
|
4
|
-
* @version 3.1.
|
|
4
|
+
* @version 3.1.9
|
|
5
5
|
* @author nuintun <nuintun@qq.com>
|
|
6
6
|
* @description A static files serving middleware for koa.
|
|
7
7
|
* @see https://github.com/nuintun/koa-files#readme
|
|
@@ -148,13 +148,13 @@ function parseRanges(context, stats) {
|
|
|
148
148
|
// Parsed entries.
|
|
149
149
|
const entries = parsed.entries();
|
|
150
150
|
// Range boundary.
|
|
151
|
-
const boundary =
|
|
151
|
+
const boundary = `${generate(32)}`;
|
|
152
152
|
// Multipart Content-Type.
|
|
153
153
|
const contentType = `Content-Type: ${context.type}`;
|
|
154
154
|
// Range suffix.
|
|
155
155
|
const suffix = Buffer.from(`\r\n--${boundary}--\r\n`);
|
|
156
156
|
// Override Content-Type.
|
|
157
|
-
context.type = `multipart/byteranges; boundary
|
|
157
|
+
context.type = `multipart/byteranges; boundary="${boundary}"`;
|
|
158
158
|
// Map ranges.
|
|
159
159
|
for (const [index, { start, end }] of entries) {
|
|
160
160
|
const length = end - start + 1;
|
package/esm/utils/path.js
CHANGED
package/esm/utils/stream.js
CHANGED
package/package.json
CHANGED
package/types/utils/hash.d.ts
CHANGED