@minto-ai/tools 1.0.670 → 1.0.671

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.
@@ -1,5 +1,5 @@
1
1
  /**
2
- * 将任意格式的 URL 路径规范化为完整的绝对 URL 地址
2
+ * 规范化 URL 路径为绝对路径
3
3
  * @param rawUrl - 待规范化的原始 URL 路径,支持空值、相对路径、绝对路径等格式
4
4
  * @returns 规范化后的绝对 URL 字符串,空输入返回空字符串
5
5
  */
package/dist/index.js CHANGED
@@ -13754,25 +13754,95 @@ function createAudioPermission() {
13754
13754
  }
13755
13755
  return audioPermissionInstance;
13756
13756
  }
13757
+ function isNumber(value) {
13758
+ return typeof value === "number";
13759
+ }
13760
+ function isString$1(value) {
13761
+ return typeof value === "string";
13762
+ }
13763
+ function beParsedAsNumber(value) {
13764
+ if (isNumber(value)) {
13765
+ return value;
13766
+ }
13767
+ if (isString$1(value)) {
13768
+ return Number.parseFloat(value);
13769
+ }
13770
+ return Number.NaN;
13771
+ }
13772
+ function canBeParsedAsNumber(value) {
13773
+ return !Number.isNaN(Number.parseFloat(String(value))) && Number.isFinite(Number(value));
13774
+ }
13775
+ function isArray$1(value) {
13776
+ return Array.isArray(value);
13777
+ }
13778
+ function checkArrayEmpty(value) {
13779
+ return isArray$1(value) && value.length === 0;
13780
+ }
13781
+ function isObject$1(value) {
13782
+ return _typeof(value) === "object" && value !== null;
13783
+ }
13784
+ function checkObjectEmpty(value) {
13785
+ return isObject$1(value) && Object.keys(value).length === 0;
13786
+ }
13787
+ function checkEmpty(value) {
13788
+ return [value === "", value === 0, checkArrayEmpty(value), checkObjectEmpty(value), value === null, value === void 0].some(Boolean);
13789
+ }
13790
+ function checkEmptyNotZero(value) {
13791
+ return checkEmpty(value) && value !== 0;
13792
+ }
13793
+ function isBoolean(value) {
13794
+ return typeof value === "boolean";
13795
+ }
13796
+ function isFunction$1(value) {
13797
+ return typeof value === "function";
13798
+ }
13799
+ function isNullOrUndefined2(value) {
13800
+ return value === null || value === void 0;
13801
+ }
13802
+ function isUndefined(value) {
13803
+ return value === void 0;
13804
+ }
13805
+ var DATA_URI_PREFIX = "data:";
13806
+ var BASE64_MARKER = ";base64,";
13807
+ var BASE64_REGEX = /^[A-Z0-9+/]+={0,2}$/i;
13808
+ function isValidBase64(value) {
13809
+ if (!isString$1(value)) {
13810
+ return false;
13811
+ }
13812
+ var str = value.trim();
13813
+ if (!str) {
13814
+ return false;
13815
+ }
13816
+ if (str.startsWith(DATA_URI_PREFIX)) {
13817
+ var markerIndex = str.indexOf(BASE64_MARKER);
13818
+ if (markerIndex === -1) {
13819
+ return false;
13820
+ }
13821
+ str = str.slice(markerIndex + BASE64_MARKER.length);
13822
+ }
13823
+ var content = str.replace(/\s+/g, "");
13824
+ if (content.length % 4 !== 0) {
13825
+ return false;
13826
+ }
13827
+ return BASE64_REGEX.test(content);
13828
+ }
13829
+ var URL_REGEX = /^https?:\/\/(?:[\w-]+:[\w-]+@)?(?:localhost|(?:[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?\.)+[a-z]{2,}|(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)\.(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)\.(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)\.(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d))(?::\d{1,5})?(?:\/[^\s?#]*)?(?:\?[^\s#]*)?(?:#\S*)?$/i;
13830
+ function isValidUrl(value) {
13831
+ if (!isString$1(value)) {
13832
+ return false;
13833
+ }
13834
+ return URL_REGEX.test(value.trim());
13835
+ }
13757
13836
  function getAbsoluteUrl(rawUrl) {
13758
13837
  if (!rawUrl) {
13759
13838
  return "";
13760
13839
  }
13761
- try {
13762
- var absoluteUrl = new URL(rawUrl).toString();
13763
- return absoluteUrl;
13764
- } catch (_unused) {
13765
- try {
13766
- var currentPageUrl = window.location.href;
13767
- var _absoluteUrl = new URL(rawUrl, currentPageUrl).toString();
13768
- return _absoluteUrl;
13769
- } catch (_unused2) {
13770
- var siteOrigin = window.location.origin;
13771
- var normalizedPath = rawUrl.startsWith("/") ? rawUrl : "/".concat(rawUrl);
13772
- var _absoluteUrl2 = "".concat(siteOrigin).concat(normalizedPath).replace(/\/+/g, "/");
13773
- return _absoluteUrl2;
13774
- }
13840
+ if (isValidUrl(rawUrl)) {
13841
+ return rawUrl;
13775
13842
  }
13843
+ var currentPageUrl = window.location.href;
13844
+ var absoluteUrl = new URL(rawUrl, currentPageUrl).toString();
13845
+ return absoluteUrl;
13776
13846
  }
13777
13847
  function murmurHash332Gc(key) {
13778
13848
  var seed = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : 0;
@@ -13900,54 +13970,6 @@ function isPc() {
13900
13970
  return !isMobile();
13901
13971
  }
13902
13972
  var DEFAULT_USER_AVATAR = "https://1-future-tuzai.obs.cn-southwest-2.myhuaweicloud.com/web_image/default.png";
13903
- function isNumber(value) {
13904
- return typeof value === "number";
13905
- }
13906
- function isString$1(value) {
13907
- return typeof value === "string";
13908
- }
13909
- function beParsedAsNumber(value) {
13910
- if (isNumber(value)) {
13911
- return value;
13912
- }
13913
- if (isString$1(value)) {
13914
- return Number.parseFloat(value);
13915
- }
13916
- return Number.NaN;
13917
- }
13918
- function canBeParsedAsNumber(value) {
13919
- return !Number.isNaN(Number.parseFloat(String(value))) && Number.isFinite(Number(value));
13920
- }
13921
- function isArray$1(value) {
13922
- return Array.isArray(value);
13923
- }
13924
- function checkArrayEmpty(value) {
13925
- return isArray$1(value) && value.length === 0;
13926
- }
13927
- function isObject$1(value) {
13928
- return _typeof(value) === "object" && value !== null;
13929
- }
13930
- function checkObjectEmpty(value) {
13931
- return isObject$1(value) && Object.keys(value).length === 0;
13932
- }
13933
- function checkEmpty(value) {
13934
- return [value === "", value === 0, checkArrayEmpty(value), checkObjectEmpty(value), value === null, value === void 0].some(Boolean);
13935
- }
13936
- function checkEmptyNotZero(value) {
13937
- return checkEmpty(value) && value !== 0;
13938
- }
13939
- function isBoolean(value) {
13940
- return typeof value === "boolean";
13941
- }
13942
- function isFunction$1(value) {
13943
- return typeof value === "function";
13944
- }
13945
- function isNullOrUndefined2(value) {
13946
- return value === null || value === void 0;
13947
- }
13948
- function isUndefined(value) {
13949
- return value === void 0;
13950
- }
13951
13973
  var FileSuffixEnum = {
13952
13974
  DOCX: "docx",
13953
13975
  DOC: "doc",
@@ -14258,37 +14280,6 @@ function isVideoFilePath(filePath) {
14258
14280
  var fileSuffix = getFileSuffix(filePath);
14259
14281
  return Object.values(VideoFileSuffixEnum).includes(fileSuffix);
14260
14282
  }
14261
- var DATA_URI_PREFIX = "data:";
14262
- var BASE64_MARKER = ";base64,";
14263
- var BASE64_REGEX = /^[A-Z0-9+/]+={0,2}$/i;
14264
- function isValidBase64(value) {
14265
- if (!isString$1(value)) {
14266
- return false;
14267
- }
14268
- var str = value.trim();
14269
- if (!str) {
14270
- return false;
14271
- }
14272
- if (str.startsWith(DATA_URI_PREFIX)) {
14273
- var markerIndex = str.indexOf(BASE64_MARKER);
14274
- if (markerIndex === -1) {
14275
- return false;
14276
- }
14277
- str = str.slice(markerIndex + BASE64_MARKER.length);
14278
- }
14279
- var content = str.replace(/\s+/g, "");
14280
- if (content.length % 4 !== 0) {
14281
- return false;
14282
- }
14283
- return BASE64_REGEX.test(content);
14284
- }
14285
- var URL_REGEX = /^https?:\/\/(?:[\w-]+:[\w-]+@)?(?:localhost|(?:[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?\.)+[a-z]{2,}|(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)\.(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)\.(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)\.(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d))(?::\d{1,5})?(?:\/[^\s?#]*)?(?:\?[^\s#]*)?(?:#\S*)?$/i;
14286
- function isValidUrl(value) {
14287
- if (!isString$1(value)) {
14288
- return false;
14289
- }
14290
- return URL_REGEX.test(value.trim());
14291
- }
14292
14283
  function singleDownloadFile(_x, _x2) {
14293
14284
  return _singleDownloadFile.apply(this, arguments);
14294
14285
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@minto-ai/tools",
3
3
  "type": "module",
4
- "version": "1.0.670",
4
+ "version": "1.0.671",
5
5
  "description": "明途公共工具库",
6
6
  "author": "hcc",
7
7
  "license": "ISC",