xshell 1.0.39 → 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/index.d.ts CHANGED
@@ -1,3 +1,4 @@
1
+ export * from './path.js';
1
2
  export * from './prototype.js';
2
3
  export * from './utils.js';
3
4
  export * from './file.js';
package/index.js CHANGED
@@ -1,3 +1,4 @@
1
+ export * from './path.js';
1
2
  export * from './prototype.js';
2
3
  export * from './utils.js';
3
4
  export * from './file.js';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "xshell",
3
- "version": "1.0.39",
3
+ "version": "1.0.41",
4
4
  "type": "module",
5
5
  "main": "./index.js",
6
6
  "bin": {
package/path.d.ts CHANGED
@@ -69,6 +69,7 @@ export declare function format(pathObject: FormatInputPathObject): string;
69
69
  export declare function toNamespacedPath(path: string): any;
70
70
  export declare const posix: npath.PlatformPath;
71
71
  export declare const win32: npath.PlatformPath;
72
+ /** 统一使用 / 作为分隔符的 path 模块 */
72
73
  export declare let path: {
73
74
  to_fp: typeof to_fp;
74
75
  normalize: typeof normalize;
package/path.js CHANGED
@@ -99,6 +99,7 @@ export function toNamespacedPath(path) {
99
99
  }
100
100
  export const posix = npath.posix;
101
101
  export const win32 = npath.win32;
102
+ /** 统一使用 / 作为分隔符的 path 模块 */
102
103
  export let path = {
103
104
  to_fp,
104
105
  normalize,
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.isdir);
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);