module-develop-kit 1.2.2 → 1.2.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/dist/main.d.ts CHANGED
@@ -57,9 +57,8 @@ export declare function detectFileByExtension(file: File, _allowedExtensions: TM
57
57
 
58
58
  /**
59
59
  * 检测文件真实类型并验证 MIME 类型
60
- *
61
60
  * @param file 要检测的文件
62
- * @param _allowedMimes 允许的MIME类型列表 支持单个或者数组。单个支持使用,分割
61
+ * @param _allowedMimes 允许的MIME类型列表 支持单个或者数组。单个支持使用,分割,支持通配符
63
62
  * @param options 检测选项
64
63
  * @returns 检测结果
65
64
  */
@@ -347,6 +346,8 @@ export declare function isValidFile(file: File, maxSize?: number): Promise<IFile
347
346
 
348
347
  /**
349
348
  * 便捷方法: 检测是否为图片文件(基于 MIME 类型)
349
+ * @file 要检测的文件
350
+ * @maxSize 文件最大尺寸
350
351
  */
351
352
  export declare function isValidImage(file: File, maxSize?: number): Promise<IFileDetectionResult>;
352
353
 
@@ -376,7 +377,7 @@ export declare interface IUrlSanitizeOptions {
376
377
  */
377
378
  fallbackUrl?: string;
378
379
  /**
379
- * 是否严格模式,严格模式下只允许 http/https,默认 false
380
+ * 是否严格模式,严格模式下只允许 http/https,默认 true
380
381
  */
381
382
  strictMode?: boolean;
382
383
  }
@@ -1,4 +1,4 @@
1
- const i = ["http:", "https:", "mailto:", "tel:", "sms:", "ftp:", "ftps:"], o = [
1
+ const i = ["http:", "https:", "mailto:", "tel:", "sms:", "ftp:", "ftps:"], n = [
2
2
  // eslint-disable-next-line no-script-url
3
3
  "javascript:",
4
4
  "data:",
@@ -7,11 +7,11 @@ const i = ["http:", "https:", "mailto:", "tel:", "sms:", "ftp:", "ftps:"], o = [
7
7
  "about:",
8
8
  "blob:"
9
9
  ];
10
- function l(t) {
10
+ function c(t) {
11
11
  return t.replace(/[​-‍]/g, "").replace(/\s+/g, "").trim();
12
12
  }
13
- function n(t) {
14
- const e = t.toLowerCase();
13
+ function a(t) {
14
+ const r = t.toLowerCase();
15
15
  return [
16
16
  /javascript:/i,
17
17
  /data:text\/html/i,
@@ -25,35 +25,35 @@ function n(t) {
25
25
  // URL 编码的 javascript
26
26
  /\\u006a\\u0061\\u0076\\u0061/i
27
27
  // Unicode 编码
28
- ].some((s) => s.test(e) || s.test(t));
28
+ ].some((s) => s.test(r) || s.test(t));
29
29
  }
30
- function c(t, e = {}) {
30
+ function l(t, r = {}) {
31
31
  if (!t || typeof t != "string")
32
32
  return !1;
33
- const r = t.trim();
34
- if (!r)
33
+ const e = t.trim();
34
+ if (!e)
35
35
  return !1;
36
- if (r.startsWith("/") || r.startsWith("./") || r.startsWith("../"))
37
- return e.allowRelative === !1 ? !1 : !n(r);
38
- const s = l(r);
39
- if (n(s))
36
+ if (e.startsWith("/") || e.startsWith("./") || e.startsWith("../"))
37
+ return r.allowRelative === !1 ? !1 : !a(e);
38
+ const s = c(e);
39
+ if (a(s))
40
40
  return !1;
41
41
  try {
42
- const a = new URL(s, "http://example.com").protocol.toLowerCase();
43
- return e.strictMode ? a === "http:" || a === "https:" : o.includes(a) ? !1 : [...i, ...e.extraSafeProtocols || []].includes(a);
42
+ const o = new URL(s, "http://example.com").protocol.toLowerCase();
43
+ return r.strictMode ?? !0 ? ["http:", "https:", ...r.extraSafeProtocols || []].includes(o) : n.includes(o) ? !1 : [...i, ...r.extraSafeProtocols || []].includes(o);
44
44
  } catch {
45
45
  return !1;
46
46
  }
47
47
  }
48
- function f(t, e = {}) {
49
- const r = e.fallbackUrl || "#";
50
- return c(t, e) ? t.trim() : r;
48
+ function f(t, r = {}) {
49
+ const e = r.fallbackUrl || "#";
50
+ return l(t, r) ? t.trim() : e;
51
51
  }
52
- function m(t, e = {}) {
53
- return t.map((r) => f(r, e));
52
+ function P(t, r = {}) {
53
+ return t.map((e) => f(e, r));
54
54
  }
55
55
  export {
56
- c as isUrlSafe,
56
+ l as isUrlSafe,
57
57
  f as sanitizeUrl,
58
- m as sanitizeUrls
58
+ P as sanitizeUrls
59
59
  };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "module-develop-kit",
3
3
  "author": "Front-End team",
4
- "version": "1.2.2",
4
+ "version": "1.2.3",
5
5
  "type": "module",
6
6
  "description": "前端项目通用工具包",
7
7
  "module": "dist/main.js",