util-helpers 4.12.9 → 4.13.0

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.
Files changed (47) hide show
  1. package/README.md +8 -1
  2. package/dist/util-helpers.js +133 -115
  3. package/dist/util-helpers.js.map +1 -1
  4. package/dist/util-helpers.min.js +1 -1
  5. package/dist/util-helpers.min.js.map +1 -1
  6. package/esm/calculateCursorPosition.js +6 -7
  7. package/esm/formatBankCard.js +5 -5
  8. package/esm/formatMobile.js +4 -3
  9. package/esm/formatMoney.js +9 -10
  10. package/esm/isBankCard.js +5 -6
  11. package/esm/isChinese.js +7 -6
  12. package/esm/isIdCard.js +5 -6
  13. package/esm/isPassword.js +7 -8
  14. package/esm/isTWCard.js +3 -4
  15. package/esm/isUrl.js +28 -6
  16. package/esm/numberToChinese.js +14 -15
  17. package/esm/replaceChar.js +10 -9
  18. package/esm/utils/config.js +1 -1
  19. package/esm/validatePassword.js +7 -8
  20. package/lib/calculateCursorPosition.js +6 -7
  21. package/lib/formatBankCard.js +5 -5
  22. package/lib/formatMobile.js +4 -3
  23. package/lib/formatMoney.js +9 -10
  24. package/lib/isBankCard.js +5 -6
  25. package/lib/isChinese.js +7 -6
  26. package/lib/isIdCard.js +5 -6
  27. package/lib/isPassword.js +7 -8
  28. package/lib/isTWCard.js +3 -4
  29. package/lib/isUrl.js +28 -6
  30. package/lib/numberToChinese.js +14 -15
  31. package/lib/replaceChar.js +10 -9
  32. package/lib/utils/config.js +1 -1
  33. package/lib/validatePassword.js +7 -8
  34. package/package.json +1 -1
  35. package/types/calculateCursorPosition.d.ts +1 -1
  36. package/types/formatBankCard.d.ts +1 -1
  37. package/types/formatMobile.d.ts +1 -1
  38. package/types/formatMoney.d.ts +1 -1
  39. package/types/isBankCard.d.ts +1 -1
  40. package/types/isChinese.d.ts +3 -1
  41. package/types/isIdCard.d.ts +1 -1
  42. package/types/isPassword.d.ts +1 -1
  43. package/types/isTWCard.d.ts +1 -1
  44. package/types/isUrl.d.ts +12 -3
  45. package/types/numberToChinese.d.ts +1 -1
  46. package/types/replaceChar.d.ts +1 -1
  47. package/types/validatePassword.d.ts +1 -1
package/README.md CHANGED
@@ -24,7 +24,7 @@ yarn add util-helpers
24
24
 
25
25
  如果你的项目使用的是原生方式开发,可以在浏览器中使用 `script` 标签直接引入文件,并使用全局变量 `utilHelpers` 。
26
26
 
27
- `npm` 包的 `util-helpers/dist` 目录下提供了 `UMD` 包 `util-helpers.js` 以及 `util-helpers.min.js`。你也可以通过 [UNPKG](https://unpkg.com/browse/util-helpers/dist/) 下载到本地进行使用。或者直接使用 [UNPKG 线上版本](https://unpkg.com/util-helpers)<sup> _注意版本_ </sup>。
27
+ `npm` 包的 `util-helpers/dist` 目录下提供了 `UMD` 包 `util-helpers.js` 以及 `util-helpers.min.js`。你也可以通过 [UNPKG](https://unpkg.com/browse/util-helpers/dist/) 下载到本地进行使用。或者直接使用 [UNPKG 线上版本](https://unpkg.com/util-helpers/dist/util-helpers.min.js)<sup> _注意版本_ </sup>。
28
28
 
29
29
  ## 示例
30
30
 
@@ -105,6 +105,7 @@ formatMoney('1000'); // => 1,000.00
105
105
  - [store2] - 丰富了 localStorage 和 sessionStorage 功能(JSON,命名空间,扩展等)
106
106
  - [uuid] - 生成通用唯一识别码(Universally Unique Identifier)
107
107
  - [JSZip] - 创建、读取和编辑 zip 文件
108
+ - [ua-parser-js] - 用于从用户代理数据中检测浏览器、引擎、操作系统、CPU 和设备类型/型号
108
109
 
109
110
  [lodash]: https://www.npmjs.com/package/lodash
110
111
  [query-string]: https://www.npmjs.com/package/query-string
@@ -123,3 +124,9 @@ formatMoney('1000'); // => 1,000.00
123
124
  [npm]: https://img.shields.io/npm/v/util-helpers.svg
124
125
  [npm-url]: https://npmjs.com/package/util-helpers
125
126
  [what is commitlint]: https://github.com/conventional-changelog/commitlint#what-is-commitlint
127
+ [ua-parser-js]: https://www.npmjs.com/package/ua-parser-js
128
+ [numeral]: http://numeraljs.com/
129
+ [rxjs]: https://www.npmjs.com/package/rxjs
130
+ [immutable]: https://www.npmjs.com/package/immutable
131
+ [classnames]: https://www.npmjs.com/package/classnames
132
+ [ramda]: https://www.npmjs.com/package/ramda
@@ -139,7 +139,7 @@
139
139
  return convertToString(value);
140
140
  }
141
141
 
142
- var reg$d = /^1[3456789]\d{9}$/;
142
+ var reg$c = /^1[3456789]\d{9}$/;
143
143
  /**
144
144
  * 检测值是否为手机号码
145
145
  *
@@ -157,10 +157,10 @@
157
157
 
158
158
  function isMobile(value) {
159
159
  var valueStr = normalizeString(value);
160
- return reg$d.test(valueStr);
160
+ return reg$c.test(valueStr);
161
161
  }
162
162
 
163
- var reg$c = /^(0\d{2,3}\-)?([2-9]\d{6,7})(\-\d{1,6})?$/;
163
+ var reg$b = /^(0\d{2,3}\-)?([2-9]\d{6,7})(\-\d{1,6})?$/;
164
164
  /**
165
165
  * 检测值是否为固定电话
166
166
  *
@@ -184,10 +184,10 @@
184
184
 
185
185
  function isTelephone(value) {
186
186
  var valueStr = normalizeString(value);
187
- return reg$c.test(valueStr);
187
+ return reg$b.test(valueStr);
188
188
  }
189
189
 
190
- var reg$b = /^\d{6}$/;
190
+ var reg$a = /^\d{6}$/;
191
191
  /**
192
192
  * 检测值是否为邮政编码,6位数字
193
193
  *
@@ -205,7 +205,7 @@
205
205
 
206
206
  function isPostcode(value) {
207
207
  var valueStr = normalizeString(value);
208
- return reg$b.test(valueStr);
208
+ return reg$a.test(valueStr);
209
209
  }
210
210
 
211
211
  var regIdCard$1 = /^[1-9]\d{5}(19|20)?\d{2}((0[1-9])|(1[012]))(([0-2][1-9])|10|20|30|31)\d{3}(\d|X)?$/i;
@@ -263,12 +263,11 @@
263
263
 
264
264
 
265
265
  function isIdCard(value) {
266
- var _ref = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {},
267
- _ref$loose = _ref.loose,
268
- loose = _ref$loose === void 0 ? false : _ref$loose,
269
- _ref$checkCode = _ref.checkCode,
270
- checkCode = _ref$checkCode === void 0 ? true : _ref$checkCode;
271
-
266
+ var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
267
+ var _options$loose = options.loose,
268
+ loose = _options$loose === void 0 ? false : _options$loose,
269
+ _options$checkCode = options.checkCode,
270
+ checkCode = _options$checkCode === void 0 ? true : _options$checkCode;
272
271
  var valueStr = normalizeString(value);
273
272
 
274
273
  if (valueStr.length === 15 && loose) {
@@ -286,7 +285,7 @@
286
285
  return false;
287
286
  }
288
287
 
289
- var reg$a = /^[\da-z]+([\-\.\_]?[\da-z]+)*@[\da-z]+([\-\.]?[\da-z]+)*(\.[a-z]{2,})+$/i;
288
+ var reg$9 = /^[\da-z]+([\-\.\_]?[\da-z]+)*@[\da-z]+([\-\.]?[\da-z]+)*(\.[a-z]{2,})+$/i;
290
289
  /**
291
290
  * 检测值是否为Email
292
291
  *
@@ -304,10 +303,10 @@
304
303
 
305
304
  function isEmail(value) {
306
305
  var valueStr = normalizeString(value);
307
- return reg$a.test(valueStr);
306
+ return reg$9.test(valueStr);
308
307
  }
309
308
 
310
- var reg$9 = /^[1-9]\d{4,10}$/;
309
+ var reg$8 = /^[1-9]\d{4,10}$/;
311
310
  /**
312
311
  * 检测值是否为QQ号,非0开头,5至11位数字
313
312
  *
@@ -325,10 +324,10 @@
325
324
 
326
325
  function isQQ(value) {
327
326
  var valueStr = normalizeString(value);
328
- return reg$9.test(valueStr);
327
+ return reg$8.test(valueStr);
329
328
  }
330
329
 
331
- var reg$8 = /^[a-z]([-_a-z0-9]{5,19})+$/i;
330
+ var reg$7 = /^[a-z]([-_a-z0-9]{5,19})+$/i;
332
331
  /**
333
332
  * 检测值是否为微信号
334
333
  *
@@ -346,10 +345,10 @@
346
345
 
347
346
  function isWX(value) {
348
347
  var valueStr = normalizeString(value);
349
- return reg$8.test(valueStr);
348
+ return reg$7.test(valueStr);
350
349
  }
351
350
 
352
- var reg$7 = /^[京津沪渝冀豫云辽黑湘皖鲁新苏浙赣鄂桂甘晋蒙陕吉闽贵粤青藏川宁琼使领A-Z]{1}[A-Z]{1}(([A-Z0-9]{4}[A-Z0-9挂学警港澳]{1})|([A-Z0-9]{5}[DF])|([DF][A-Z0-9]{5}))$/;
351
+ var reg$6 = /^[京津沪渝冀豫云辽黑湘皖鲁新苏浙赣鄂桂甘晋蒙陕吉闽贵粤青藏川宁琼使领A-Z]{1}[A-Z]{1}(([A-Z0-9]{4}[A-Z0-9挂学警港澳]{1})|([A-Z0-9]{5}[DF])|([DF][A-Z0-9]{5}))$/;
353
352
  /**
354
353
  * 检测值是否为车牌号,支持新能源和非新能源车牌
355
354
  *
@@ -375,10 +374,10 @@
375
374
 
376
375
  function isVehicle(value) {
377
376
  var valueStr = normalizeString(value);
378
- return reg$7.test(valueStr);
377
+ return reg$6.test(valueStr);
379
378
  }
380
379
 
381
- var reg$6 = /^[1-9]\d{9,20}$/; // 8~30位数字
380
+ var reg$5 = /^[1-9]\d{9,20}$/; // 8~30位数字
382
381
 
383
382
  var regLoose = /^\d{8,30}$/;
384
383
  /**
@@ -425,14 +424,13 @@
425
424
 
426
425
 
427
426
  function isBankCard(value) {
428
- var _ref = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {},
429
- _ref$loose = _ref.loose,
430
- loose = _ref$loose === void 0 ? false : _ref$loose,
431
- _ref$luhn = _ref.luhn,
432
- luhn = _ref$luhn === void 0 ? false : _ref$luhn;
433
-
427
+ var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
428
+ var _options$loose = options.loose,
429
+ loose = _options$loose === void 0 ? false : _options$loose,
430
+ _options$luhn = options.luhn,
431
+ luhn = _options$luhn === void 0 ? false : _options$luhn;
434
432
  var valueStr = normalizeString(value);
435
- var validateResult = loose ? regLoose.test(valueStr) : reg$6.test(valueStr);
433
+ var validateResult = loose ? regLoose.test(valueStr) : reg$5.test(valueStr);
436
434
 
437
435
  if (validateResult && luhn) {
438
436
  var precode = valueStr.substring(0, valueStr.length - 1);
@@ -528,7 +526,7 @@
528
526
  return lastCode === checkCode;
529
527
  }
530
528
 
531
- const version = "4.12.9";
529
+ const version = "4.13.0";
532
530
 
533
531
  // @ts-ignore
534
532
  var config = {
@@ -779,14 +777,13 @@
779
777
 
780
778
 
781
779
  function validatePassword(value) {
782
- var _ref = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {},
783
- _ref$level = _ref.level,
784
- level = _ref$level === void 0 ? 2 : _ref$level,
785
- _ref$ignoreCase = _ref.ignoreCase,
786
- ignoreCase = _ref$ignoreCase === void 0 ? false : _ref$ignoreCase,
787
- _ref$special = _ref.special,
788
- special = _ref$special === void 0 ? '\\x21-\\x2F\\x3A-\\x40\\x5B-\\x60\\x7B-\\x7E' : _ref$special;
789
-
780
+ var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
781
+ var _options$level = options.level,
782
+ level = _options$level === void 0 ? 2 : _options$level,
783
+ _options$ignoreCase = options.ignoreCase,
784
+ ignoreCase = _options$ignoreCase === void 0 ? false : _options$ignoreCase,
785
+ _options$special = options.special,
786
+ special = _options$special === void 0 ? '\\x21-\\x2F\\x3A-\\x40\\x5B-\\x60\\x7B-\\x7E' : _options$special;
790
787
  var valStr = value;
791
788
 
792
789
  if (typeof value !== 'string') {
@@ -880,14 +877,13 @@
880
877
  */
881
878
 
882
879
  function isPassword(value) {
883
- var _ref = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {},
884
- _ref$level = _ref.level,
885
- level = _ref$level === void 0 ? 2 : _ref$level,
886
- _ref$ignoreCase = _ref.ignoreCase,
887
- ignoreCase = _ref$ignoreCase === void 0 ? false : _ref$ignoreCase,
888
- _ref$special = _ref.special,
889
- special = _ref$special === void 0 ? '\\x21-\\x2F\\x3A-\\x40\\x5B-\\x60\\x7B-\\x7E' : _ref$special;
890
-
880
+ var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
881
+ var _options$level = options.level,
882
+ level = _options$level === void 0 ? 2 : _options$level,
883
+ _options$ignoreCase = options.ignoreCase,
884
+ ignoreCase = _options$ignoreCase === void 0 ? false : _options$ignoreCase,
885
+ _options$special = options.special,
886
+ special = _options$special === void 0 ? '\\x21-\\x2F\\x3A-\\x40\\x5B-\\x60\\x7B-\\x7E' : _options$special;
891
887
  return validatePassword(value, {
892
888
  level: level,
893
889
  ignoreCase: ignoreCase,
@@ -895,7 +891,7 @@
895
891
  }).validated;
896
892
  }
897
893
 
898
- var reg$5 = /^((e[\da-z])|(de)|(se)|(pe)|([khm][\da-z]))[\da-z]{7}$/i;
894
+ var reg$4 = /^((e[\da-z])|(de)|(se)|(pe)|([khm][\da-z]))[\da-z]{7}$/i;
899
895
  /**
900
896
  * 检测值是否为护照号
901
897
  * 支持普通护照(E*)、外交护照(DE)、公务护照(SE)、公务普通护照(PE)、香港特区护照(K/KJ/H*)、澳门特区护照(MA/MB/M*),注意不区分大小写
@@ -915,7 +911,7 @@
915
911
 
916
912
  function isPassport(value) {
917
913
  var valueStr = normalizeString(value);
918
- return reg$5.test(valueStr);
914
+ return reg$4.test(valueStr);
919
915
  }
920
916
 
921
917
  var chineseDictionary = {
@@ -950,6 +946,8 @@
950
946
  * @alias module:Validator.isChinese
951
947
  * @since 1.1.0
952
948
  * @see 参考 {@link http://www.unicode.org/reports/tr38/#BlockListing|4.4 Listing of Characters Covered by the Unihan Database}
949
+ * @see 参考 {@link https://zh.wikipedia.org/wiki/Unicode字符平面映射|Unicode字符平面映射}
950
+ * @see 参考 {@link https://zh.wikipedia.org/wiki/Unicode區段|Unicode区段}
953
951
  * @param {*} value 要检测的值
954
952
  * @param {Object} [options] 配置项
955
953
  * @param {boolean} [options.loose=false] 宽松模式。如果为true,只要包含中文即为true
@@ -974,12 +972,11 @@
974
972
  */
975
973
 
976
974
  function isChinese(value) {
977
- var _ref = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {},
978
- _ref$loose = _ref.loose,
979
- loose = _ref$loose === void 0 ? false : _ref$loose,
980
- _ref$useExtend = _ref.useExtend,
981
- useExtend = _ref$useExtend === void 0 ? false : _ref$useExtend;
982
-
975
+ var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
976
+ var _options$loose = options.loose,
977
+ loose = _options$loose === void 0 ? false : _options$loose,
978
+ _options$useExtend = options.useExtend,
979
+ useExtend = _options$useExtend === void 0 ? false : _options$useExtend;
983
980
  var valueStr = normalizeString(value);
984
981
  var basicRegExp = loose ? looseChineseRegExp : chineseRegExp;
985
982
  var extendRegExp = loose ? looseChineseExtendRegExp : chineseExtendRegExp;
@@ -990,7 +987,7 @@
990
987
  return reg.test(valueStr);
991
988
  }
992
989
 
993
- var reg$4 = /^((\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.){3}(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])$/;
990
+ var reg$3 = /^((\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.){3}(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])$/;
994
991
  /**
995
992
  * 检测值是否为ipv4
996
993
  *
@@ -1010,10 +1007,10 @@
1010
1007
 
1011
1008
  function isIPv4(value) {
1012
1009
  var valueStr = normalizeString(value);
1013
- return reg$4.test(valueStr);
1010
+ return reg$3.test(valueStr);
1014
1011
  }
1015
1012
 
1016
- var reg$3 = /^((([0-9A-F]{1,4}:){7}([0-9A-F]{1,4}|:))|(([0-9A-F]{1,4}:){6}(:[0-9A-F]{1,4}|((25[0-5]|2[0-4]\d|1\d\d|\d{1,2})(\.(25[0-5]|2[0-4]\d|1\d\d|\d{1,2})){3})|:))|(([0-9A-F]{1,4}:){5}(((:[0-9A-F]{1,4}){1,2})|:((25[0-5]|2[0-4]\d|1\d\d|\d{1,2})(\.(25[0-5]|2[0-4]\d|1\d\d|\d{1,2})){3})|:))|(([0-9A-F]{1,4}:){4}(((:[0-9A-F]{1,4}){1,3})|((:[0-9A-F]{1,4})?:((25[0-5]|2[0-4]\d|1\d\d|\d{1,2})(\.(25[0-5]|2[0-4]\d|1\d\d|\d{1,2})){3}))|:))|(([0-9A-F]{1,4}:){3}(((:[0-9A-F]{1,4}){1,4})|((:[0-9A-F]{1,4}){0,2}:((25[0-5]|2[0-4]\d|1\d\d|\d{1,2})(\.(25[0-5]|2[0-4]\d|1\d\d|\d{1,2})){3}))|:))|(([0-9A-F]{1,4}:){2}(((:[0-9A-F]{1,4}){1,5})|((:[0-9A-F]{1,4}){0,3}:((25[0-5]|2[0-4]\d|1\d\d|\d{1,2})(\.(25[0-5]|2[0-4]\d|1\d\d|\d{1,2})){3}))|:))|(([0-9A-F]{1,4}:){1}(((:[0-9A-F]{1,4}){1,6})|((:[0-9A-F]{1,4}){0,4}:((25[0-5]|2[0-4]\d|1\d\d|\d{1,2})(\.(25[0-5]|2[0-4]\d|1\d\d|\d{1,2})){3}))|:))|(:(((:[0-9A-F]{1,4}){1,7})|((:[0-9A-F]{1,4}){0,5}:((25[0-5]|2[0-4]\d|1\d\d|\d{1,2})(\.(25[0-5]|2[0-4]\d|1\d\d|\d{1,2})){3}))|:)))(%.+)?$/i;
1013
+ var reg$2 = /^((([0-9A-F]{1,4}:){7}([0-9A-F]{1,4}|:))|(([0-9A-F]{1,4}:){6}(:[0-9A-F]{1,4}|((25[0-5]|2[0-4]\d|1\d\d|\d{1,2})(\.(25[0-5]|2[0-4]\d|1\d\d|\d{1,2})){3})|:))|(([0-9A-F]{1,4}:){5}(((:[0-9A-F]{1,4}){1,2})|:((25[0-5]|2[0-4]\d|1\d\d|\d{1,2})(\.(25[0-5]|2[0-4]\d|1\d\d|\d{1,2})){3})|:))|(([0-9A-F]{1,4}:){4}(((:[0-9A-F]{1,4}){1,3})|((:[0-9A-F]{1,4})?:((25[0-5]|2[0-4]\d|1\d\d|\d{1,2})(\.(25[0-5]|2[0-4]\d|1\d\d|\d{1,2})){3}))|:))|(([0-9A-F]{1,4}:){3}(((:[0-9A-F]{1,4}){1,4})|((:[0-9A-F]{1,4}){0,2}:((25[0-5]|2[0-4]\d|1\d\d|\d{1,2})(\.(25[0-5]|2[0-4]\d|1\d\d|\d{1,2})){3}))|:))|(([0-9A-F]{1,4}:){2}(((:[0-9A-F]{1,4}){1,5})|((:[0-9A-F]{1,4}){0,3}:((25[0-5]|2[0-4]\d|1\d\d|\d{1,2})(\.(25[0-5]|2[0-4]\d|1\d\d|\d{1,2})){3}))|:))|(([0-9A-F]{1,4}:){1}(((:[0-9A-F]{1,4}){1,6})|((:[0-9A-F]{1,4}){0,4}:((25[0-5]|2[0-4]\d|1\d\d|\d{1,2})(\.(25[0-5]|2[0-4]\d|1\d\d|\d{1,2})){3}))|:))|(:(((:[0-9A-F]{1,4}){1,7})|((:[0-9A-F]{1,4}){0,5}:((25[0-5]|2[0-4]\d|1\d\d|\d{1,2})(\.(25[0-5]|2[0-4]\d|1\d\d|\d{1,2})){3}))|:)))(%.+)?$/i;
1017
1014
  /**
1018
1015
  * 检测值是否为ipv6
1019
1016
  *
@@ -1047,10 +1044,24 @@
1047
1044
 
1048
1045
  function isIPv6(value) {
1049
1046
  var valueStr = normalizeString(value);
1050
- return reg$3.test(valueStr);
1047
+ return reg$2.test(valueStr);
1051
1048
  }
1052
1049
 
1053
- var reg$2 = /(((^https?:(?:\/\/)?)(?:[-;:&=\+\$,\w]+@)?[A-Za-z0-9.-]+(?::\d+)?|(?:www.|[-;:&=\+\$,\w]+@)[A-Za-z0-9.-]+)((?:\/[\+~%\/.\w-_]*)?\??(?:[-\*\+=&;%@.\w_]*)#?(?:[\w]*))?)$/;
1050
+ // [协议类型]://[服务器地址]:[端口号]/[资源层级UNIX文件路径][文件名]?[查询]#[片段ID]
1051
+ // 完整格式如下:
1052
+ // [协议类型]://[访问资源需要的凭证信息]@[服务器地址]:[端口号]/[资源层级UNIX文件路径][文件名]?[查询]#[片段ID]
1053
+ //
1054
+ // 其中[访问凭证信息]、[端口号]、[查询]、[片段ID]都属于选填项。
1055
+
1056
+ var protocalReg = '[\\w-.]+:\\/\\/';
1057
+ var credentialsReg = '[-;:&=\\+\\$,\\w]+@';
1058
+ var serverReg = 'localhost|(([^\\s:\\/]+?\\.)+?[^\\s:\\/]+)';
1059
+ var portReg = ':\\d+';
1060
+ var pathReg = '\\/.*';
1061
+ var searchReg = '\\?.*';
1062
+ var hashReg = '#.*';
1063
+ var regWithProtocal = new RegExp("^".concat(protocalReg, "(?:").concat(credentialsReg, ")?(?:").concat(serverReg, ")(?:").concat(portReg, ")?(?:").concat(pathReg, ")*(?:").concat(searchReg, ")?(?:").concat(hashReg, ")?$"));
1064
+ var regNonProtocal = new RegExp("^(?:".concat(serverReg, ")(?:").concat(portReg, ")?(?:").concat(pathReg, ")*(?:").concat(searchReg, ")?(?:").concat(hashReg, ")?$"));
1054
1065
  /**
1055
1066
  * 检测值是否为url
1056
1067
  *
@@ -1063,18 +1074,27 @@
1063
1074
  * @example
1064
1075
  *
1065
1076
  * isUrl(''); // false
1066
- * isUrl('8.8.8.8'); // false
1077
+ * isUrl('/foo/bar'); // false
1078
+ *
1079
+ * isUrl('8.8.8.8'); // true
1067
1080
  * isUrl('example.com'); // true
1068
1081
  * isUrl('http://example.com'); // true
1069
1082
  * isUrl('https://example.com:8080'); // true
1070
- * isUrl('http://www.example.com/test/123'); // true
1071
- * isUrl('http://www.example.com/test/123?foo=bar'); // true
1083
+ * isUrl('https://www.example.com/test/123'); // true
1084
+ * isUrl('https://www.example.com/test/123?foo=bar'); // true
1085
+ * isUrl('https://www.example.com/test/123?foo=中文#id'); // true
1086
+ * isUrl('https://www.example.com/test/123?foo=中文#测试'); // true
1087
+ * isUrl('ftp://127.0.0.1:8080/测试.tar'); // true
1088
+ * isUrl('a.b'); // true
1089
+ * isUrl('a.b:8080'); // true
1090
+ * isUrl('p://a.b'); // true
1091
+ * isUrl('p://a.b:8888'); // true
1072
1092
  *
1073
1093
  */
1074
1094
 
1075
1095
  function isUrl(value) {
1076
1096
  var valueStr = normalizeString(value);
1077
- return reg$2.test(valueStr);
1097
+ return regWithProtocal.test(valueStr) || regNonProtocal.test(valueStr);
1078
1098
  }
1079
1099
 
1080
1100
  var baseReg = /^\d{15}$/;
@@ -1441,10 +1461,9 @@
1441
1461
  */
1442
1462
 
1443
1463
  function isTWCard(value) {
1444
- var _ref = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {},
1445
- _ref$loose = _ref.loose,
1446
- loose = _ref$loose === void 0 ? false : _ref$loose;
1447
-
1464
+ var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
1465
+ var _options$loose = options.loose,
1466
+ loose = _options$loose === void 0 ? false : _options$loose;
1448
1467
  var valueStr = normalizeString(value);
1449
1468
 
1450
1469
  if (regTWCard.test(valueStr)) {
@@ -1871,17 +1890,16 @@
1871
1890
 
1872
1891
 
1873
1892
  var formatMoney = function formatMoney(num) {
1874
- var _ref = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {},
1875
- _ref$precision = _ref.precision,
1876
- precision = _ref$precision === void 0 ? 2 : _ref$precision,
1877
- symbol = _ref.symbol,
1878
- _ref$thousand = _ref.thousand,
1879
- thousand = _ref$thousand === void 0 ? ',' : _ref$thousand,
1880
- _ref$decimal = _ref.decimal,
1881
- decimal = _ref$decimal === void 0 ? '.' : _ref$decimal;
1882
-
1883
- // 数字参数不正确,返回空字符串
1893
+ var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
1894
+ var _options$precision = options.precision,
1895
+ precision = _options$precision === void 0 ? 2 : _options$precision,
1896
+ symbol = options.symbol,
1897
+ _options$thousand = options.thousand,
1898
+ thousand = _options$thousand === void 0 ? ',' : _options$thousand,
1899
+ _options$decimal = options.decimal,
1900
+ decimal = _options$decimal === void 0 ? '.' : _options$decimal; // 数字参数不正确,返回空字符串
1884
1901
  // @ts-ignore
1902
+
1885
1903
  if (!checkNumber(num)) {
1886
1904
  return '';
1887
1905
  } // 参数规整化
@@ -1936,12 +1954,12 @@
1936
1954
 
1937
1955
  function formatBankCard() {
1938
1956
  var bankCardNo = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
1957
+ var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
1939
1958
 
1940
- var _ref = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {},
1941
- _ref$char = _ref["char"],
1942
- _char = _ref$char === void 0 ? ' ' : _ref$char,
1943
- _ref$length = _ref.length,
1944
- length = _ref$length === void 0 ? 4 : _ref$length;
1959
+ var _options$char = options["char"],
1960
+ _char = _options$char === void 0 ? ' ' : _options$char,
1961
+ _options$length = options.length,
1962
+ length = _options$length === void 0 ? 4 : _options$length;
1945
1963
 
1946
1964
  var reg = new RegExp("(.{".concat(length, "})"), 'g');
1947
1965
  var regChar = new RegExp("".concat(_char), 'g');
@@ -1990,16 +2008,17 @@
1990
2008
  */
1991
2009
 
1992
2010
  function replaceChar(str) {
1993
- var _ref = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {},
1994
- _ref$start = _ref.start,
1995
- start = _ref$start === void 0 ? 3 : _ref$start,
1996
- _ref$end = _ref.end,
1997
- end = _ref$end === void 0 ? -4 : _ref$end,
1998
- _ref$char = _ref["char"],
1999
- _char = _ref$char === void 0 ? '*' : _ref$char,
2000
- repeat = _ref.repeat,
2001
- exclude = _ref.exclude;
2011
+ var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
2002
2012
 
2013
+ var _options$char = options["char"],
2014
+ _char = _options$char === void 0 ? '*' : _options$char,
2015
+ exclude = options.exclude;
2016
+
2017
+ var _options$start = options.start,
2018
+ start = _options$start === void 0 ? 3 : _options$start,
2019
+ _options$end = options.end,
2020
+ end = _options$end === void 0 ? -4 : _options$end,
2021
+ repeat = options.repeat;
2003
2022
  var realStr = normalizeString(str);
2004
2023
  var strLen = realStr.length; // 开始位置超过str长度
2005
2024
 
@@ -2206,21 +2225,20 @@
2206
2225
 
2207
2226
 
2208
2227
  function numberToChinese(num) {
2209
- var _ref = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {},
2210
- _ref$big = _ref.big5,
2211
- big5 = _ref$big === void 0 ? false : _ref$big,
2212
- _ref$unit = _ref.unit,
2213
- unit = _ref$unit === void 0 ? true : _ref$unit,
2214
- _ref$decimal = _ref.decimal,
2215
- decimal = _ref$decimal === void 0 ? '' : _ref$decimal,
2216
- _ref$zero = _ref.zero,
2217
- zero = _ref$zero === void 0 ? '' : _ref$zero,
2218
- _ref$negative = _ref.negative,
2219
- negative = _ref$negative === void 0 ? '负' : _ref$negative,
2220
- _ref$unitConfig = _ref.unitConfig,
2221
- unitConfig = _ref$unitConfig === void 0 ? {} : _ref$unitConfig;
2222
-
2223
- // 非数字 或 NaN 不处理
2228
+ var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
2229
+ var _options$big = options.big5,
2230
+ big5 = _options$big === void 0 ? false : _options$big,
2231
+ _options$unit = options.unit,
2232
+ unit = _options$unit === void 0 ? true : _options$unit,
2233
+ _options$zero = options.zero,
2234
+ zero = _options$zero === void 0 ? '' : _options$zero,
2235
+ _options$negative = options.negative,
2236
+ negative = _options$negative === void 0 ? '' : _options$negative,
2237
+ _options$unitConfig = options.unitConfig,
2238
+ unitConfig = _options$unitConfig === void 0 ? {} : _options$unitConfig;
2239
+ var _options$decimal = options.decimal,
2240
+ decimal = _options$decimal === void 0 ? '' : _options$decimal; // 非数字 或 NaN 不处理
2241
+
2224
2242
  if (typeof num !== 'number' || isNaN(num)) {
2225
2243
  devWarn("\u53C2\u6570\u9519\u8BEF ".concat(num, "\uFF0C\u8BF7\u4F20\u5165\u6570\u5B57"));
2226
2244
  return '';
@@ -2587,9 +2605,10 @@
2587
2605
  */
2588
2606
 
2589
2607
  function formatMobile(mobileNo) {
2590
- var _ref = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {},
2591
- _ref$char = _ref["char"],
2592
- _char = _ref$char === void 0 ? ' ' : _ref$char;
2608
+ var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
2609
+
2610
+ var _options$char = options["char"],
2611
+ _char = _options$char === void 0 ? ' ' : _options$char;
2593
2612
 
2594
2613
  var regChar = new RegExp(_char, 'g');
2595
2614
  var realValue = normalizeString(mobileNo).replace(regChar, '').substring(0, 11);
@@ -2905,13 +2924,12 @@
2905
2924
  */
2906
2925
 
2907
2926
  function calculateCursorPosition(prevPos, prevCtrlValue, rawValue, ctrlValue) {
2908
- var _ref = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : {},
2909
- _ref$placeholderChar = _ref.placeholderChar,
2910
- placeholderChar = _ref$placeholderChar === void 0 ? ' ' : _ref$placeholderChar,
2911
- _ref$maskReg = _ref.maskReg,
2912
- maskReg = _ref$maskReg === void 0 ? /\D/g : _ref$maskReg,
2913
- type = _ref.type;
2914
-
2927
+ var options = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : {};
2928
+ var _options$placeholderC = options.placeholderChar,
2929
+ placeholderChar = _options$placeholderC === void 0 ? ' ' : _options$placeholderC,
2930
+ _options$maskReg = options.maskReg,
2931
+ maskReg = _options$maskReg === void 0 ? /\D/g : _options$maskReg,
2932
+ type = options.type;
2915
2933
  var realCtrlValue = normalizeString(prevCtrlValue);
2916
2934
  var realRawValue = normalizeString(rawValue);
2917
2935
  var placeholderChars = Array.isArray(placeholderChar) ? placeholderChar : [placeholderChar];