xshell 1.0.40 → 1.0.41
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/package.json +1 -1
- package/server.js +2 -3
package/package.json
CHANGED
package/server.js
CHANGED
|
@@ -14,6 +14,7 @@ import KoaCors from '@koa/cors';
|
|
|
14
14
|
import KoaCompress from 'koa-compress';
|
|
15
15
|
import { userAgent as KoaUserAgent } from 'koa-useragent';
|
|
16
16
|
// --- my libs
|
|
17
|
+
import { t } from './i18n/instance.js';
|
|
17
18
|
import { request as _request } from './net.js';
|
|
18
19
|
import { stream_to_buffer, inspect, output_width, assert } from './utils.js';
|
|
19
20
|
import { fstat } from './file.js';
|
|
@@ -306,11 +307,9 @@ export class Server {
|
|
|
306
307
|
- absolute?: `false` 使用绝对路径指定发送的文件
|
|
307
308
|
- download?: `undefined` 在 response.headers 中加上 content-disposition: attachment 指示浏览器下载文件 */
|
|
308
309
|
async fsend(ctx, fp, { root, absolute, download, } = {}) {
|
|
309
|
-
assert(root
|
|
310
|
+
assert(absolute || root?.isdir, t('fsend 必须传 absolute 选项或 root 文件夹'));
|
|
310
311
|
const { request } = ctx;
|
|
311
312
|
let { response } = ctx;
|
|
312
|
-
if (!absolute && !root)
|
|
313
|
-
throw new Error('fsend with `!absolute && !root`');
|
|
314
313
|
if (!absolute) {
|
|
315
314
|
if (fp.startsWith(root))
|
|
316
315
|
fp = fp.slice(root.length);
|