@bigbinary/neeto-form-frontend 4.4.58 → 4.4.59-beta2

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 (42) hide show
  1. package/dist/.ready +1 -1
  2. package/dist/BuildForm.js +1 -1
  3. package/dist/ExternalForm.js +2 -2
  4. package/dist/Submission.js +383 -384
  5. package/dist/Submission.js.map +1 -1
  6. package/dist/UrlBuilder.js +2 -2
  7. package/dist/cjs/BuildForm.js +1 -1
  8. package/dist/cjs/ExternalForm.js +2 -2
  9. package/dist/cjs/Submission.js +383 -384
  10. package/dist/cjs/Submission.js.map +1 -1
  11. package/dist/cjs/UrlBuilder.js +2 -2
  12. package/dist/cjs/index.js +2 -2
  13. package/dist/cjs/{utils-zVNwUbdx.js → utils-BpyTbv4T.js} +2 -2
  14. package/dist/cjs/{utils-zVNwUbdx.js.map → utils-BpyTbv4T.js.map} +1 -1
  15. package/dist/cjs/v2/BuildForm.js +1 -1
  16. package/dist/cjs/v2/ExternalForm.js +2 -2
  17. package/dist/cjs/v2/Submission.js +383 -384
  18. package/dist/cjs/v2/Submission.js.map +1 -1
  19. package/dist/cjs/v2/UrlBuilder.js +2 -2
  20. package/dist/cjs/v2/index.js +2 -2
  21. package/dist/cjs/v2/{utils-CjowRPXH.js → utils-BEmzx_CT.js} +2 -2
  22. package/dist/cjs/v2/{utils-CjowRPXH.js.map → utils-BEmzx_CT.js.map} +1 -1
  23. package/dist/cjs/v2/{yup-DSCAoUTF.js → yup-BJdUP8f6.js} +12 -12
  24. package/dist/cjs/v2/{yup-DSCAoUTF.js.map → yup-BJdUP8f6.js.map} +1 -1
  25. package/dist/cjs/{yup-BPzvBMfE.js → yup-C1tUTQs0.js} +12 -12
  26. package/dist/cjs/{yup-BPzvBMfE.js.map → yup-C1tUTQs0.js.map} +1 -1
  27. package/dist/index.js +2 -2
  28. package/dist/{utils-CMGhbRpZ.js → utils-DwvyMha8.js} +2 -2
  29. package/dist/{utils-CMGhbRpZ.js.map → utils-DwvyMha8.js.map} +1 -1
  30. package/dist/v2/BuildForm.js +1 -1
  31. package/dist/v2/ExternalForm.js +2 -2
  32. package/dist/v2/Submission.js +383 -384
  33. package/dist/v2/Submission.js.map +1 -1
  34. package/dist/v2/UrlBuilder.js +2 -2
  35. package/dist/v2/index.js +2 -2
  36. package/dist/v2/{utils-UvAB6bbG.js → utils-Dng9m1z9.js} +2 -2
  37. package/dist/v2/{utils-UvAB6bbG.js.map → utils-Dng9m1z9.js.map} +1 -1
  38. package/dist/v2/{yup-BaiHo-7Z.js → yup-hYIKNz1B.js} +12 -12
  39. package/dist/v2/{yup-BaiHo-7Z.js.map → yup-hYIKNz1B.js.map} +1 -1
  40. package/dist/{yup-CzoKyYgO.js → yup-TxS0SXvr.js} +12 -12
  41. package/dist/{yup-CzoKyYgO.js.map → yup-TxS0SXvr.js.map} +1 -1
  42. package/package.json +4 -4
@@ -60,309 +60,295 @@ defaultHrefDecorator.default = function (href) {
60
60
 
61
61
  var defaultMatchDecorator = {};
62
62
 
63
- var regex$3;
64
- var hasRequiredRegex$3;
65
-
66
- function requireRegex$3 () {
67
- if (hasRequiredRegex$3) return regex$3;
68
- hasRequiredRegex$3 = 1;
69
- regex$3=/[\0-\uD7FF\uE000-\uFFFF]|[\uD800-\uDBFF][\uDC00-\uDFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF]/;
70
- return regex$3;
71
- }
63
+ var index_cjs$1 = {};
72
64
 
73
- var regex$2;
74
- var hasRequiredRegex$2;
65
+ var regex$5 = /[\0-\uD7FF\uE000-\uFFFF]|[\uD800-\uDBFF][\uDC00-\uDFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF]/;
75
66
 
76
- function requireRegex$2 () {
77
- if (hasRequiredRegex$2) return regex$2;
78
- hasRequiredRegex$2 = 1;
79
- regex$2=/[\0-\x1F\x7F-\x9F]/;
80
- return regex$2;
81
- }
67
+ var regex$4 = /[\0-\x1F\x7F-\x9F]/;
82
68
 
83
- var regex$1;
84
- var hasRequiredRegex$1;
69
+ var regex$3 = /[\xAD\u0600-\u0605\u061C\u06DD\u070F\u0890\u0891\u08E2\u180E\u200B-\u200F\u202A-\u202E\u2060-\u2064\u2066-\u206F\uFEFF\uFFF9-\uFFFB]|\uD804[\uDCBD\uDCCD]|\uD80D[\uDC30-\uDC3F]|\uD82F[\uDCA0-\uDCA3]|\uD834[\uDD73-\uDD7A]|\uDB40[\uDC01\uDC20-\uDC7F]/;
85
70
 
86
- function requireRegex$1 () {
87
- if (hasRequiredRegex$1) return regex$1;
88
- hasRequiredRegex$1 = 1;
89
- regex$1=/[ \xA0\u1680\u2000-\u200A\u2028\u2029\u202F\u205F\u3000]/;
90
- return regex$1;
91
- }
71
+ var regex$2 = /[!-#%-\*,-\/:;\?@\[-\]_\{\}\xA1\xA7\xAB\xB6\xB7\xBB\xBF\u037E\u0387\u055A-\u055F\u0589\u058A\u05BE\u05C0\u05C3\u05C6\u05F3\u05F4\u0609\u060A\u060C\u060D\u061B\u061D-\u061F\u066A-\u066D\u06D4\u0700-\u070D\u07F7-\u07F9\u0830-\u083E\u085E\u0964\u0965\u0970\u09FD\u0A76\u0AF0\u0C77\u0C84\u0DF4\u0E4F\u0E5A\u0E5B\u0F04-\u0F12\u0F14\u0F3A-\u0F3D\u0F85\u0FD0-\u0FD4\u0FD9\u0FDA\u104A-\u104F\u10FB\u1360-\u1368\u1400\u166E\u169B\u169C\u16EB-\u16ED\u1735\u1736\u17D4-\u17D6\u17D8-\u17DA\u1800-\u180A\u1944\u1945\u1A1E\u1A1F\u1AA0-\u1AA6\u1AA8-\u1AAD\u1B5A-\u1B60\u1B7D\u1B7E\u1BFC-\u1BFF\u1C3B-\u1C3F\u1C7E\u1C7F\u1CC0-\u1CC7\u1CD3\u2010-\u2027\u2030-\u2043\u2045-\u2051\u2053-\u205E\u207D\u207E\u208D\u208E\u2308-\u230B\u2329\u232A\u2768-\u2775\u27C5\u27C6\u27E6-\u27EF\u2983-\u2998\u29D8-\u29DB\u29FC\u29FD\u2CF9-\u2CFC\u2CFE\u2CFF\u2D70\u2E00-\u2E2E\u2E30-\u2E4F\u2E52-\u2E5D\u3001-\u3003\u3008-\u3011\u3014-\u301F\u3030\u303D\u30A0\u30FB\uA4FE\uA4FF\uA60D-\uA60F\uA673\uA67E\uA6F2-\uA6F7\uA874-\uA877\uA8CE\uA8CF\uA8F8-\uA8FA\uA8FC\uA92E\uA92F\uA95F\uA9C1-\uA9CD\uA9DE\uA9DF\uAA5C-\uAA5F\uAADE\uAADF\uAAF0\uAAF1\uABEB\uFD3E\uFD3F\uFE10-\uFE19\uFE30-\uFE52\uFE54-\uFE61\uFE63\uFE68\uFE6A\uFE6B\uFF01-\uFF03\uFF05-\uFF0A\uFF0C-\uFF0F\uFF1A\uFF1B\uFF1F\uFF20\uFF3B-\uFF3D\uFF3F\uFF5B\uFF5D\uFF5F-\uFF65]|\uD800[\uDD00-\uDD02\uDF9F\uDFD0]|\uD801\uDD6F|\uD802[\uDC57\uDD1F\uDD3F\uDE50-\uDE58\uDE7F\uDEF0-\uDEF6\uDF39-\uDF3F\uDF99-\uDF9C]|\uD803[\uDEAD\uDF55-\uDF59\uDF86-\uDF89]|\uD804[\uDC47-\uDC4D\uDCBB\uDCBC\uDCBE-\uDCC1\uDD40-\uDD43\uDD74\uDD75\uDDC5-\uDDC8\uDDCD\uDDDB\uDDDD-\uDDDF\uDE38-\uDE3D\uDEA9]|\uD805[\uDC4B-\uDC4F\uDC5A\uDC5B\uDC5D\uDCC6\uDDC1-\uDDD7\uDE41-\uDE43\uDE60-\uDE6C\uDEB9\uDF3C-\uDF3E]|\uD806[\uDC3B\uDD44-\uDD46\uDDE2\uDE3F-\uDE46\uDE9A-\uDE9C\uDE9E-\uDEA2\uDF00-\uDF09]|\uD807[\uDC41-\uDC45\uDC70\uDC71\uDEF7\uDEF8\uDF43-\uDF4F\uDFFF]|\uD809[\uDC70-\uDC74]|\uD80B[\uDFF1\uDFF2]|\uD81A[\uDE6E\uDE6F\uDEF5\uDF37-\uDF3B\uDF44]|\uD81B[\uDE97-\uDE9A\uDFE2]|\uD82F\uDC9F|\uD836[\uDE87-\uDE8B]|\uD83A[\uDD5E\uDD5F]/;
92
72
 
93
- var regex;
94
- var hasRequiredRegex;
73
+ var regex$1 = /[\$\+<->\^`\|~\xA2-\xA6\xA8\xA9\xAC\xAE-\xB1\xB4\xB8\xD7\xF7\u02C2-\u02C5\u02D2-\u02DF\u02E5-\u02EB\u02ED\u02EF-\u02FF\u0375\u0384\u0385\u03F6\u0482\u058D-\u058F\u0606-\u0608\u060B\u060E\u060F\u06DE\u06E9\u06FD\u06FE\u07F6\u07FE\u07FF\u0888\u09F2\u09F3\u09FA\u09FB\u0AF1\u0B70\u0BF3-\u0BFA\u0C7F\u0D4F\u0D79\u0E3F\u0F01-\u0F03\u0F13\u0F15-\u0F17\u0F1A-\u0F1F\u0F34\u0F36\u0F38\u0FBE-\u0FC5\u0FC7-\u0FCC\u0FCE\u0FCF\u0FD5-\u0FD8\u109E\u109F\u1390-\u1399\u166D\u17DB\u1940\u19DE-\u19FF\u1B61-\u1B6A\u1B74-\u1B7C\u1FBD\u1FBF-\u1FC1\u1FCD-\u1FCF\u1FDD-\u1FDF\u1FED-\u1FEF\u1FFD\u1FFE\u2044\u2052\u207A-\u207C\u208A-\u208C\u20A0-\u20C0\u2100\u2101\u2103-\u2106\u2108\u2109\u2114\u2116-\u2118\u211E-\u2123\u2125\u2127\u2129\u212E\u213A\u213B\u2140-\u2144\u214A-\u214D\u214F\u218A\u218B\u2190-\u2307\u230C-\u2328\u232B-\u2426\u2440-\u244A\u249C-\u24E9\u2500-\u2767\u2794-\u27C4\u27C7-\u27E5\u27F0-\u2982\u2999-\u29D7\u29DC-\u29FB\u29FE-\u2B73\u2B76-\u2B95\u2B97-\u2BFF\u2CE5-\u2CEA\u2E50\u2E51\u2E80-\u2E99\u2E9B-\u2EF3\u2F00-\u2FD5\u2FF0-\u2FFF\u3004\u3012\u3013\u3020\u3036\u3037\u303E\u303F\u309B\u309C\u3190\u3191\u3196-\u319F\u31C0-\u31E3\u31EF\u3200-\u321E\u322A-\u3247\u3250\u3260-\u327F\u328A-\u32B0\u32C0-\u33FF\u4DC0-\u4DFF\uA490-\uA4C6\uA700-\uA716\uA720\uA721\uA789\uA78A\uA828-\uA82B\uA836-\uA839\uAA77-\uAA79\uAB5B\uAB6A\uAB6B\uFB29\uFBB2-\uFBC2\uFD40-\uFD4F\uFDCF\uFDFC-\uFDFF\uFE62\uFE64-\uFE66\uFE69\uFF04\uFF0B\uFF1C-\uFF1E\uFF3E\uFF40\uFF5C\uFF5E\uFFE0-\uFFE6\uFFE8-\uFFEE\uFFFC\uFFFD]|\uD800[\uDD37-\uDD3F\uDD79-\uDD89\uDD8C-\uDD8E\uDD90-\uDD9C\uDDA0\uDDD0-\uDDFC]|\uD802[\uDC77\uDC78\uDEC8]|\uD805\uDF3F|\uD807[\uDFD5-\uDFF1]|\uD81A[\uDF3C-\uDF3F\uDF45]|\uD82F\uDC9C|\uD833[\uDF50-\uDFC3]|\uD834[\uDC00-\uDCF5\uDD00-\uDD26\uDD29-\uDD64\uDD6A-\uDD6C\uDD83\uDD84\uDD8C-\uDDA9\uDDAE-\uDDEA\uDE00-\uDE41\uDE45\uDF00-\uDF56]|\uD835[\uDEC1\uDEDB\uDEFB\uDF15\uDF35\uDF4F\uDF6F\uDF89\uDFA9\uDFC3]|\uD836[\uDC00-\uDDFF\uDE37-\uDE3A\uDE6D-\uDE74\uDE76-\uDE83\uDE85\uDE86]|\uD838[\uDD4F\uDEFF]|\uD83B[\uDCAC\uDCB0\uDD2E\uDEF0\uDEF1]|\uD83C[\uDC00-\uDC2B\uDC30-\uDC93\uDCA0-\uDCAE\uDCB1-\uDCBF\uDCC1-\uDCCF\uDCD1-\uDCF5\uDD0D-\uDDAD\uDDE6-\uDE02\uDE10-\uDE3B\uDE40-\uDE48\uDE50\uDE51\uDE60-\uDE65\uDF00-\uDFFF]|\uD83D[\uDC00-\uDED7\uDEDC-\uDEEC\uDEF0-\uDEFC\uDF00-\uDF76\uDF7B-\uDFD9\uDFE0-\uDFEB\uDFF0]|\uD83E[\uDC00-\uDC0B\uDC10-\uDC47\uDC50-\uDC59\uDC60-\uDC87\uDC90-\uDCAD\uDCB0\uDCB1\uDD00-\uDE53\uDE60-\uDE6D\uDE70-\uDE7C\uDE80-\uDE88\uDE90-\uDEBD\uDEBF-\uDEC5\uDECE-\uDEDB\uDEE0-\uDEE8\uDEF0-\uDEF8\uDF00-\uDF92\uDF94-\uDFCA]/;
95
74
 
96
- function requireRegex () {
97
- if (hasRequiredRegex) return regex;
98
- hasRequiredRegex = 1;
99
- regex=/[!-#%-\*,-\/:;\?@\[-\]_\{\}\xA1\xA7\xAB\xB6\xB7\xBB\xBF\u037E\u0387\u055A-\u055F\u0589\u058A\u05BE\u05C0\u05C3\u05C6\u05F3\u05F4\u0609\u060A\u060C\u060D\u061B\u061E\u061F\u066A-\u066D\u06D4\u0700-\u070D\u07F7-\u07F9\u0830-\u083E\u085E\u0964\u0965\u0970\u09FD\u0A76\u0AF0\u0C84\u0DF4\u0E4F\u0E5A\u0E5B\u0F04-\u0F12\u0F14\u0F3A-\u0F3D\u0F85\u0FD0-\u0FD4\u0FD9\u0FDA\u104A-\u104F\u10FB\u1360-\u1368\u1400\u166D\u166E\u169B\u169C\u16EB-\u16ED\u1735\u1736\u17D4-\u17D6\u17D8-\u17DA\u1800-\u180A\u1944\u1945\u1A1E\u1A1F\u1AA0-\u1AA6\u1AA8-\u1AAD\u1B5A-\u1B60\u1BFC-\u1BFF\u1C3B-\u1C3F\u1C7E\u1C7F\u1CC0-\u1CC7\u1CD3\u2010-\u2027\u2030-\u2043\u2045-\u2051\u2053-\u205E\u207D\u207E\u208D\u208E\u2308-\u230B\u2329\u232A\u2768-\u2775\u27C5\u27C6\u27E6-\u27EF\u2983-\u2998\u29D8-\u29DB\u29FC\u29FD\u2CF9-\u2CFC\u2CFE\u2CFF\u2D70\u2E00-\u2E2E\u2E30-\u2E4E\u3001-\u3003\u3008-\u3011\u3014-\u301F\u3030\u303D\u30A0\u30FB\uA4FE\uA4FF\uA60D-\uA60F\uA673\uA67E\uA6F2-\uA6F7\uA874-\uA877\uA8CE\uA8CF\uA8F8-\uA8FA\uA8FC\uA92E\uA92F\uA95F\uA9C1-\uA9CD\uA9DE\uA9DF\uAA5C-\uAA5F\uAADE\uAADF\uAAF0\uAAF1\uABEB\uFD3E\uFD3F\uFE10-\uFE19\uFE30-\uFE52\uFE54-\uFE61\uFE63\uFE68\uFE6A\uFE6B\uFF01-\uFF03\uFF05-\uFF0A\uFF0C-\uFF0F\uFF1A\uFF1B\uFF1F\uFF20\uFF3B-\uFF3D\uFF3F\uFF5B\uFF5D\uFF5F-\uFF65]|\uD800[\uDD00-\uDD02\uDF9F\uDFD0]|\uD801\uDD6F|\uD802[\uDC57\uDD1F\uDD3F\uDE50-\uDE58\uDE7F\uDEF0-\uDEF6\uDF39-\uDF3F\uDF99-\uDF9C]|\uD803[\uDF55-\uDF59]|\uD804[\uDC47-\uDC4D\uDCBB\uDCBC\uDCBE-\uDCC1\uDD40-\uDD43\uDD74\uDD75\uDDC5-\uDDC8\uDDCD\uDDDB\uDDDD-\uDDDF\uDE38-\uDE3D\uDEA9]|\uD805[\uDC4B-\uDC4F\uDC5B\uDC5D\uDCC6\uDDC1-\uDDD7\uDE41-\uDE43\uDE60-\uDE6C\uDF3C-\uDF3E]|\uD806[\uDC3B\uDE3F-\uDE46\uDE9A-\uDE9C\uDE9E-\uDEA2]|\uD807[\uDC41-\uDC45\uDC70\uDC71\uDEF7\uDEF8]|\uD809[\uDC70-\uDC74]|\uD81A[\uDE6E\uDE6F\uDEF5\uDF37-\uDF3B\uDF44]|\uD81B[\uDE97-\uDE9A]|\uD82F\uDC9F|\uD836[\uDE87-\uDE8B]|\uD83A[\uDD5E\uDD5F]/;
100
- return regex;
101
- }
75
+ var regex = /[ \xA0\u1680\u2000-\u200A\u2028\u2029\u202F\u205F\u3000]/;
102
76
 
103
- var re;
104
- var hasRequiredRe;
77
+ index_cjs$1.Any = regex$5;
78
+ index_cjs$1.Cc = regex$4;
79
+ index_cjs$1.Cf = regex$3;
80
+ index_cjs$1.P = regex$2;
81
+ index_cjs$1.S = regex$1;
82
+ index_cjs$1.Z = regex;
105
83
 
106
- function requireRe () {
107
- if (hasRequiredRe) return re;
108
- hasRequiredRe = 1;
84
+ var uc_micro = index_cjs$1;
109
85
 
86
+ function reFactory (opts) {
87
+ const re = {};
88
+ opts = opts || {};
110
89
 
111
- re = function (opts) {
112
- var re = {};
90
+ re.src_Any = uc_micro.Any.source;
91
+ re.src_Cc = uc_micro.Cc.source;
92
+ re.src_Z = uc_micro.Z.source;
93
+ re.src_P = uc_micro.P.source;
113
94
 
114
- // Use direct extract instead of `regenerate` to reduse browserified size
115
- re.src_Any = requireRegex$3().source;
116
- re.src_Cc = requireRegex$2().source;
117
- re.src_Z = requireRegex$1().source;
118
- re.src_P = requireRegex().source;
95
+ // \p{\Z\P\Cc\CF} (white spaces + control + format + punctuation)
96
+ re.src_ZPCc = [re.src_Z, re.src_P, re.src_Cc].join('|');
119
97
 
120
- // \p{\Z\P\Cc\CF} (white spaces + control + format + punctuation)
121
- re.src_ZPCc = [ re.src_Z, re.src_P, re.src_Cc ].join('|');
98
+ // \p{\Z\Cc} (white spaces + control)
99
+ re.src_ZCc = [re.src_Z, re.src_Cc].join('|');
122
100
 
123
- // \p{\Z\Cc} (white spaces + control)
124
- re.src_ZCc = [ re.src_Z, re.src_Cc ].join('|');
125
-
126
- // Experimental. List of chars, completely prohibited in links
127
- // because can separate it from other part of text
128
- var text_separators = '[><\uff5c]';
101
+ // Experimental. List of chars, completely prohibited in links
102
+ // because can separate it from other part of text
103
+ const text_separators = '[><\uff5c]';
129
104
 
130
- // All possible word characters (everything without punctuation, spaces & controls)
131
- // Defined via punctuation & spaces to save space
132
- // Should be something like \p{\L\N\S\M} (\w but without `_`)
133
- re.src_pseudo_letter = '(?:(?!' + text_separators + '|' + re.src_ZPCc + ')' + re.src_Any + ')';
134
- // The same as abothe but without [0-9]
135
- // var src_pseudo_letter_non_d = '(?:(?![0-9]|' + src_ZPCc + ')' + src_Any + ')';
105
+ // All possible word characters (everything without punctuation, spaces & controls)
106
+ // Defined via punctuation & spaces to save space
107
+ // Should be something like \p{\L\N\S\M} (\w but without `_`)
108
+ re.src_pseudo_letter = `(?:(?!${text_separators}|${re.src_ZPCc})${re.src_Any})`;
109
+ // The same as abothe but without [0-9]
110
+ // var src_pseudo_letter_non_d = '(?:(?![0-9]|' + src_ZPCc + ')' + src_Any + ')';
136
111
 
137
- ////////////////////////////////////////////////////////////////////////////////
112
+ re.src_ip4 =
138
113
 
139
- re.src_ip4 =
114
+ '(?:(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\.){3}(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)';
140
115
 
141
- '(?:(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\.){3}(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)';
116
+ // Prohibit any of "@/[]()" in user/pass to avoid wrong domain fetch.
117
+ // Length is capped to exclude possible rescans till the end and avoid O(n^2)
118
+ // DoS. No standard limit, just take something reasonable.
119
+ re.src_auth = `(?:(?:(?!${re.src_ZCc}|[@/\\[\\]()]).){1,50}@)?`;
142
120
 
143
- // Prohibit any of "@/[]()" in user/pass to avoid wrong domain fetch.
144
- re.src_auth = '(?:(?:(?!' + re.src_ZCc + '|[@/\\[\\]()]).)+@)?';
121
+ re.src_port =
145
122
 
146
- re.src_port =
123
+ '(?::(?:6(?:[0-4]\\d{3}|5(?:[0-4]\\d{2}|5(?:[0-2]\\d|3[0-5])))|[1-5]?\\d{1,4}))?';
147
124
 
148
- '(?::(?:6(?:[0-4]\\d{3}|5(?:[0-4]\\d{2}|5(?:[0-2]\\d|3[0-5])))|[1-5]?\\d{1,4}))?';
125
+ re.src_host_terminator =
149
126
 
150
- re.src_host_terminator =
127
+ `(?=$|${text_separators}|${re.src_ZPCc})` +
128
+ `(?!${opts['---'] ? '-(?!--)|' : '-|'}_|:\\d|\\.-|\\.(?!$|${re.src_ZPCc}))`;
151
129
 
152
- '(?=$|' + text_separators + '|' + re.src_ZPCc + ')(?!-|_|:\\d|\\.-|\\.(?!$|' + re.src_ZPCc + '))';
130
+ re.src_path =
153
131
 
154
- re.src_path =
132
+ '(?:' +
133
+ '[/?#]' +
134
+ '(?:' +
135
+ `(?!${re.src_ZCc}|${text_separators}|[()[\\]{}.,"'?!\\-;]).|` +
136
+ `\\[(?:(?!${re.src_ZCc}|\\]).)*\\]|` +
137
+ `\\((?:(?!${re.src_ZCc}|[)]).)*\\)|` +
138
+ `\\{(?:(?!${re.src_ZCc}|[}]).)*\\}|` +
139
+ `\\"(?:(?!${re.src_ZCc}|["]).)+\\"|` +
140
+ `\\'(?:(?!${re.src_ZCc}|[']).)+\\'|` +
155
141
 
156
- '(?:' +
157
- '[/?#]' +
158
- '(?:' +
159
- '(?!' + re.src_ZCc + '|' + text_separators + '|[()[\\]{}.,"\'?!\\-]).|' +
160
- '\\[(?:(?!' + re.src_ZCc + '|\\]).)*\\]|' +
161
- '\\((?:(?!' + re.src_ZCc + '|[)]).)*\\)|' +
162
- '\\{(?:(?!' + re.src_ZCc + '|[}]).)*\\}|' +
163
- '\\"(?:(?!' + re.src_ZCc + '|["]).)+\\"|' +
164
- "\\'(?:(?!" + re.src_ZCc + "|[']).)+\\'|" +
165
- "\\'(?=" + re.src_pseudo_letter + '|[-]).|' + // allow `I'm_king` if no pair found
166
- '\\.{2,4}[a-zA-Z0-9%/]|' + // github has ... in commit range links,
167
- // google has .... in links (issue #66)
168
- // Restrict to
169
- // - english
170
- // - percent-encoded
171
- // - parts of file path
172
- // until more examples found.
173
- '\\.(?!' + re.src_ZCc + '|[.]).|' +
174
- (opts && opts['---'] ?
175
- '\\-(?!--(?:[^-]|$))(?:-*)|' // `---` => long dash, terminate
176
- :
177
- '\\-+|'
178
- ) +
179
- '\\,(?!' + re.src_ZCc + ').|' + // allow `,,,` in paths
180
- '\\!(?!' + re.src_ZCc + '|[!]).|' +
181
- '\\?(?!' + re.src_ZCc + '|[?]).' +
182
- ')+' +
183
- '|\\/' +
184
- ')?';
142
+ // allow `I'm_king` if no pair found
143
+ `\\'(?=${re.src_pseudo_letter}|[-])|` +
185
144
 
186
- // Allow anything in markdown spec, forbid quote (") at the first position
187
- // because emails enclosed in quotes are far more common
188
- re.src_email_name =
145
+ // google has many dots in "google search" links (#66, #81).
146
+ // github has ... in commit range links,
147
+ // Restrict to
148
+ // - english
149
+ // - percent-encoded
150
+ // - parts of file path
151
+ // - params separator
152
+ // until more examples found.
153
+ '\\.{2,}[a-zA-Z0-9%/&]|' +
189
154
 
190
- '[\\-;:&=\\+\\$,\\.a-zA-Z0-9_][\\-;:&=\\+\\$,\\"\\.a-zA-Z0-9_]*';
155
+ `\\.(?!${re.src_ZCc}|[.]|$)|` +
156
+ (opts['---']
157
+ ? '\\-(?!--(?:[^-]|$))(?:-*)|' // `---` => long dash, terminate
158
+ : '\\-+|'
159
+ ) +
160
+ // allow `,,,` in paths
161
+ `,(?!${re.src_ZCc}|$)|` +
191
162
 
192
- re.src_xn =
163
+ // allow `;` if not followed by space-like char
164
+ `;(?!${re.src_ZCc}|$)|` +
193
165
 
194
- 'xn--[a-z0-9\\-]{1,59}';
166
+ // allow `!!!` in paths, but not at the end
167
+ `\\!+(?!${re.src_ZCc}|[!]|$)|` +
195
168
 
196
- // More to read about domain names
197
- // http://serverfault.com/questions/638260/
169
+ `\\?(?!${re.src_ZCc}|[?]|$)` +
170
+ ')+' +
171
+ '|\\/' +
172
+ ')?';
198
173
 
199
- re.src_domain_root =
174
+ // Allow anything in markdown spec, forbid quote (") at the first position
175
+ // because emails enclosed in quotes are far more common
176
+ // Max name length capped to 64 chars (RFC 5321). This also prevents O(n^2)
177
+ // rescans to the end on inputs like `mailto:mailto:...`
178
+ re.src_email_name =
200
179
 
201
- // Allow letters & digits (http://test1)
202
- '(?:' +
203
- re.src_xn +
204
- '|' +
205
- re.src_pseudo_letter + '{1,63}' +
206
- ')';
180
+ '[\\-;:&=\\+\\$,\\.a-zA-Z0-9_][\\-;:&=\\+\\$,\\"\\.a-zA-Z0-9_]{0,63}';
207
181
 
208
- re.src_domain =
182
+ re.src_xn =
209
183
 
210
- '(?:' +
211
- re.src_xn +
212
- '|' +
213
- '(?:' + re.src_pseudo_letter + ')' +
214
- '|' +
215
- '(?:' + re.src_pseudo_letter + '(?:-|' + re.src_pseudo_letter + '){0,61}' + re.src_pseudo_letter + ')' +
216
- ')';
184
+ 'xn--[a-z0-9\\-]{1,59}';
217
185
 
218
- re.src_host =
186
+ // More to read about domain names
187
+ // http://serverfault.com/questions/638260/
219
188
 
220
- '(?:' +
221
- // Don't need IP check, because digits are already allowed in normal domain names
222
- // src_ip4 +
223
- // '|' +
224
- '(?:(?:(?:' + re.src_domain + ')\\.)*' + re.src_domain/*_root*/ + ')' +
225
- ')';
189
+ re.src_domain_root =
226
190
 
227
- re.tpl_host_fuzzy =
191
+ // Allow letters & digits (http://test1)
192
+ '(?:' +
193
+ re.src_xn +
194
+ '|' +
195
+ `${re.src_pseudo_letter}{1,63}` +
196
+ ')';
228
197
 
229
- '(?:' +
230
- re.src_ip4 +
231
- '|' +
232
- '(?:(?:(?:' + re.src_domain + ')\\.)+(?:%TLDS%))' +
233
- ')';
198
+ re.src_domain =
234
199
 
235
- re.tpl_host_no_ip_fuzzy =
200
+ '(?:' +
201
+ re.src_xn +
202
+ '|' +
203
+ `(?:${re.src_pseudo_letter})` +
204
+ '|' +
205
+ `(?:${re.src_pseudo_letter}(?:-|${re.src_pseudo_letter}){0,61}${re.src_pseudo_letter})` +
206
+ ')';
236
207
 
237
- '(?:(?:(?:' + re.src_domain + ')\\.)+(?:%TLDS%))';
208
+ re.src_host =
238
209
 
239
- re.src_host_strict =
210
+ '(?:' +
211
+ // Don't need IP check, because digits are already allowed in normal domain names
212
+ // src_ip4 +
213
+ // '|' +
214
+ `(?:(?:(?:${re.src_domain})\\.)*${re.src_domain})`/* _root */ +
215
+ ')';
240
216
 
241
- re.src_host + re.src_host_terminator;
217
+ re.tpl_host_fuzzy =
242
218
 
243
- re.tpl_host_fuzzy_strict =
219
+ '(?:' +
220
+ re.src_ip4 +
221
+ '|' +
222
+ `(?:(?:(?:${re.src_domain})\\.)+(?:%TLDS%))` +
223
+ ')';
244
224
 
245
- re.tpl_host_fuzzy + re.src_host_terminator;
225
+ re.tpl_host_no_ip_fuzzy =
246
226
 
247
- re.src_host_port_strict =
227
+ `(?:(?:(?:${re.src_domain})\\.)+(?:%TLDS%))`;
248
228
 
249
- re.src_host + re.src_port + re.src_host_terminator;
229
+ re.src_host_strict =
250
230
 
251
- re.tpl_host_port_fuzzy_strict =
231
+ re.src_host + re.src_host_terminator;
252
232
 
253
- re.tpl_host_fuzzy + re.src_port + re.src_host_terminator;
233
+ re.tpl_host_fuzzy_strict =
254
234
 
255
- re.tpl_host_port_no_ip_fuzzy_strict =
235
+ re.tpl_host_fuzzy + re.src_host_terminator;
256
236
 
257
- re.tpl_host_no_ip_fuzzy + re.src_port + re.src_host_terminator;
237
+ re.src_host_port_strict =
258
238
 
239
+ re.src_host + re.src_port + re.src_host_terminator;
259
240
 
260
- ////////////////////////////////////////////////////////////////////////////////
261
- // Main rules
241
+ re.tpl_host_port_fuzzy_strict =
262
242
 
263
- // Rude test fuzzy links by host, for quick deny
264
- re.tpl_host_fuzzy_test =
243
+ re.tpl_host_fuzzy + re.src_port + re.src_host_terminator;
265
244
 
266
- 'localhost|www\\.|\\.\\d{1,3}\\.|(?:\\.(?:%TLDS%)(?:' + re.src_ZPCc + '|>|$))';
245
+ re.tpl_host_port_no_ip_fuzzy_strict =
267
246
 
268
- re.tpl_email_fuzzy =
247
+ re.tpl_host_no_ip_fuzzy + re.src_port + re.src_host_terminator;
248
+
249
+ //
250
+ // Main rules
251
+ //
269
252
 
270
- '(^|' + text_separators + '|"|\\(|' + re.src_ZCc + ')' +
271
- '(' + re.src_email_name + '@' + re.tpl_host_fuzzy_strict + ')';
253
+ // Rude test fuzzy links by host, for quick deny
254
+ re.tpl_host_fuzzy_test =
272
255
 
273
- re.tpl_link_fuzzy =
274
- // Fuzzy link can't be prepended with .:/\- and non punctuation.
275
- // but can start with > (markdown blockquote)
276
- '(^|(?![.:/\\-_@])(?:[$+<=>^`|\uff5c]|' + re.src_ZPCc + '))' +
277
- '((?![$+<=>^`|\uff5c])' + re.tpl_host_port_fuzzy_strict + re.src_path + ')';
256
+ `localhost|www\\.|\\.\\d{1,3}\\.|(?:\\.(?:%TLDS%)(?:${re.src_ZPCc}|>|$))`;
278
257
 
279
- re.tpl_link_no_ip_fuzzy =
280
- // Fuzzy link can't be prepended with .:/\- and non punctuation.
281
- // but can start with > (markdown blockquote)
282
- '(^|(?![.:/\\-_@])(?:[$+<=>^`|\uff5c]|' + re.src_ZPCc + '))' +
283
- '((?![$+<=>^`|\uff5c])' + re.tpl_host_port_no_ip_fuzzy_strict + re.src_path + ')';
258
+ re.tpl_email_fuzzy =
284
259
 
285
- return re;
286
- };
287
- return re;
260
+ `(^|${text_separators}|"|\\(|${re.src_ZCc})` +
261
+ `(${re.src_email_name}@${re.tpl_host_fuzzy_strict})`;
262
+
263
+ re.tpl_link_fuzzy =
264
+ // Fuzzy link can't be prepended with .:/\- and non punctuation.
265
+ // but can start with > (markdown blockquote)
266
+ `(^|(?![.:/\\-_@])(?:[$+<=>^\`|\uff5c]|${re.src_ZPCc}))` +
267
+ `((?![$+<=>^\`|\uff5c])${re.tpl_host_port_fuzzy_strict}${re.src_path})`;
268
+
269
+ re.tpl_link_no_ip_fuzzy =
270
+ // Fuzzy link can't be prepended with .:/\- and non punctuation.
271
+ // but can start with > (markdown blockquote)
272
+ `(^|(?![.:/\\-_@])(?:[$+<=>^\`|\uff5c]|${re.src_ZPCc}))` +
273
+ `((?![$+<=>^\`|\uff5c])${re.tpl_host_port_no_ip_fuzzy_strict}${re.src_path})`;
274
+
275
+ return re
288
276
  }
289
277
 
290
- ////////////////////////////////////////////////////////////////////////////////
278
+ //
291
279
  // Helpers
280
+ //
292
281
 
293
282
  // Merge objects
294
283
  //
295
- function assign(obj /*from1, from2, from3, ...*/) {
296
- var sources = Array.prototype.slice.call(arguments, 1);
284
+ function assign (obj /* from1, from2, from3, ... */) {
285
+ const sources = Array.prototype.slice.call(arguments, 1);
297
286
 
298
287
  sources.forEach(function (source) {
299
- if (!source) { return; }
288
+ if (!source) { return }
300
289
 
301
290
  Object.keys(source).forEach(function (key) {
302
291
  obj[key] = source[key];
303
292
  });
304
293
  });
305
294
 
306
- return obj;
295
+ return obj
307
296
  }
308
297
 
309
- function _class(obj) { return Object.prototype.toString.call(obj); }
310
- function isString(obj) { return _class(obj) === '[object String]'; }
311
- function isObject(obj) { return _class(obj) === '[object Object]'; }
312
- function isRegExp(obj) { return _class(obj) === '[object RegExp]'; }
313
- function isFunction(obj) { return _class(obj) === '[object Function]'; }
314
-
298
+ function _class (obj) { return Object.prototype.toString.call(obj) }
299
+ function isString (obj) { return _class(obj) === '[object String]' }
300
+ function isObject (obj) { return _class(obj) === '[object Object]' }
301
+ function isRegExp (obj) { return _class(obj) === '[object RegExp]' }
302
+ function isFunction (obj) { return _class(obj) === '[object Function]' }
315
303
 
316
- function escapeRE(str) { return str.replace(/[.?*+^$[\]\\(){}|-]/g, '\\$&'); }
317
-
318
- ////////////////////////////////////////////////////////////////////////////////
304
+ function escapeRE (str) { return str.replace(/[.?*+^$[\]\\(){}|-]/g, '\\$&') }
319
305
 
306
+ //
320
307
 
321
- var defaultOptions = {
308
+ const defaultOptions = {
322
309
  fuzzyLink: true,
323
310
  fuzzyEmail: true,
324
311
  fuzzyIP: false
325
312
  };
326
313
 
327
-
328
- function isOptionsObj(obj) {
314
+ function isOptionsObj (obj) {
329
315
  return Object.keys(obj || {}).reduce(function (acc, k) {
330
- return acc || defaultOptions.hasOwnProperty(k);
331
- }, false);
316
+ /* eslint-disable-next-line no-prototype-builtins */
317
+ return acc || defaultOptions.hasOwnProperty(k)
318
+ }, false)
332
319
  }
333
320
 
334
-
335
- var defaultSchemas = {
321
+ const defaultSchemas = {
336
322
  'http:': {
337
323
  validate: function (text, pos, self) {
338
- var tail = text.slice(pos);
324
+ const tail = text.slice(pos);
339
325
 
340
326
  if (!self.re.http) {
341
327
  // compile lazily, because "host"-containing variables can change on tlds update.
342
- self.re.http = new RegExp(
343
- '^\\/\\/' + self.re.src_auth + self.re.src_host_port_strict + self.re.src_path, 'i'
328
+ self.re.http = new RegExp(
329
+ `^\\/\\/${self.re.src_auth}${self.re.src_host_port_strict}${self.re.src_path}`, 'i'
344
330
  );
345
331
  }
346
332
  if (self.re.http.test(tail)) {
347
- return tail.match(self.re.http)[0].length;
333
+ return tail.match(self.re.http)[0].length
348
334
  }
349
- return 0;
335
+ return 0
350
336
  }
351
337
  },
352
- 'https:': 'http:',
353
- 'ftp:': 'http:',
354
- '//': {
338
+ 'https:': 'http:',
339
+ 'ftp:': 'http:',
340
+ '//': {
355
341
  validate: function (text, pos, self) {
356
- var tail = text.slice(pos);
342
+ const tail = text.slice(pos);
357
343
 
358
344
  if (!self.re.no_http) {
359
345
  // compile lazily, because "host"-containing variables can change on tlds update.
360
- self.re.no_http = new RegExp(
346
+ self.re.no_http = new RegExp(
361
347
  '^' +
362
348
  self.re.src_auth +
363
349
  // Don't allow single-level domains, because of false positives like '//test'
364
350
  // with code comments
365
- '(?:localhost|(?:(?:' + self.re.src_domain + ')\\.)+' + self.re.src_domain_root + ')' +
351
+ `(?:localhost|(?:(?:${self.re.src_domain})\\.)+${self.re.src_domain_root})` +
366
352
  self.re.src_port +
367
353
  self.re.src_host_terminator +
368
354
  self.re.src_path,
@@ -373,73 +359,61 @@ var defaultSchemas = {
373
359
 
374
360
  if (self.re.no_http.test(tail)) {
375
361
  // should not be `://` & `///`, that protects from errors in protocol name
376
- if (pos >= 3 && text[pos - 3] === ':') { return 0; }
377
- if (pos >= 3 && text[pos - 3] === '/') { return 0; }
378
- return tail.match(self.re.no_http)[0].length;
362
+ if (pos >= 3 && text[pos - 3] === ':') { return 0 }
363
+ if (pos >= 3 && text[pos - 3] === '/') { return 0 }
364
+ return tail.match(self.re.no_http)[0].length
379
365
  }
380
- return 0;
366
+ return 0
381
367
  }
382
368
  },
383
369
  'mailto:': {
384
370
  validate: function (text, pos, self) {
385
- var tail = text.slice(pos);
371
+ const tail = text.slice(pos);
386
372
 
387
373
  if (!self.re.mailto) {
388
- self.re.mailto = new RegExp(
389
- '^' + self.re.src_email_name + '@' + self.re.src_host_strict, 'i'
374
+ self.re.mailto = new RegExp(
375
+ `^${self.re.src_email_name}@${self.re.src_host_strict}`, 'i'
390
376
  );
391
377
  }
392
378
  if (self.re.mailto.test(tail)) {
393
- return tail.match(self.re.mailto)[0].length;
379
+ return tail.match(self.re.mailto)[0].length
394
380
  }
395
- return 0;
381
+ return 0
396
382
  }
397
383
  }
398
384
  };
399
385
 
400
- /*eslint-disable max-len*/
401
-
402
386
  // RE pattern for 2-character tlds (autogenerated by ./support/tlds_2char_gen.js)
403
- var tlds_2ch_src_re = 'a[cdefgilmnoqrstuwxz]|b[abdefghijmnorstvwyz]|c[acdfghiklmnoruvwxyz]|d[ejkmoz]|e[cegrstu]|f[ijkmor]|g[abdefghilmnpqrstuwy]|h[kmnrtu]|i[delmnoqrst]|j[emop]|k[eghimnprwyz]|l[abcikrstuvy]|m[acdeghklmnopqrstuvwxyz]|n[acefgilopruz]|om|p[aefghklmnrstwy]|qa|r[eosuw]|s[abcdeghijklmnortuvxyz]|t[cdfghjklmnortvwz]|u[agksyz]|v[aceginu]|w[fs]|y[et]|z[amw]';
387
+ const tlds_2ch_src_re = 'a[cdefgilmnoqrstuwxz]|b[abdefghijmnorstvwyz]|c[acdfghiklmnoruvwxyz]|d[ejkmoz]|e[cegrstu]|f[ijkmor]|g[abdefghilmnpqrstuwy]|h[kmnrtu]|i[delmnoqrst]|j[emop]|k[eghimnprwyz]|l[abcikrstuvy]|m[acdeghklmnopqrstuvwxyz]|n[acefgilopruz]|om|p[aefghklmnrstwy]|qa|r[eosuw]|s[abcdeghijklmnortuvxyz]|t[cdfghjklmnortvwz]|u[agksyz]|v[aceginu]|w[fs]|y[et]|z[amw]';
404
388
 
405
389
  // DON'T try to make PRs with changes. Extend TLDs with LinkifyIt.tlds() instead
406
- var tlds_default = 'biz|com|edu|gov|net|org|pro|web|xxx|aero|asia|coop|info|museum|name|shop|рф'.split('|');
407
-
408
- /*eslint-enable max-len*/
390
+ const tlds_default = 'biz|com|edu|gov|net|org|pro|web|xxx|aero|asia|coop|info|museum|name|shop|рф'.split('|');
409
391
 
410
- ////////////////////////////////////////////////////////////////////////////////
411
-
412
- function resetScanCache(self) {
413
- self.__index__ = -1;
414
- self.__text_cache__ = '';
415
- }
416
-
417
- function createValidator(re) {
392
+ function createValidator (re) {
418
393
  return function (text, pos) {
419
- var tail = text.slice(pos);
394
+ const tail = text.slice(pos);
420
395
 
421
396
  if (re.test(tail)) {
422
- return tail.match(re)[0].length;
397
+ return tail.match(re)[0].length
423
398
  }
424
- return 0;
425
- };
399
+ return 0
400
+ }
426
401
  }
427
402
 
428
- function createNormalizer() {
403
+ function createNormalizer () {
429
404
  return function (match, self) {
430
405
  self.normalize(match);
431
- };
406
+ }
432
407
  }
433
408
 
434
409
  // Schemas compiler. Build regexps.
435
410
  //
436
- function compile(self) {
437
-
411
+ function compile (self) {
438
412
  // Load & clone RE patterns.
439
- var re = self.re = requireRe()(self.__opts__);
413
+ const re = self.re = reFactory(self.__opts__);
440
414
 
441
415
  // Define dynamic patterns
442
- var tlds = self.__tlds__.slice();
416
+ const tlds = self.__tlds__.slice();
443
417
 
444
418
  self.onCompile();
445
419
 
@@ -450,32 +424,35 @@ function compile(self) {
450
424
 
451
425
  re.src_tlds = tlds.join('|');
452
426
 
453
- function untpl(tpl) { return tpl.replace('%TLDS%', re.src_tlds); }
427
+ function untpl (tpl) { return tpl.replace('%TLDS%', re.src_tlds) }
454
428
 
455
- re.email_fuzzy = RegExp(untpl(re.tpl_email_fuzzy), 'i');
456
- re.link_fuzzy = RegExp(untpl(re.tpl_link_fuzzy), 'i');
429
+ re.email_fuzzy = RegExp(untpl(re.tpl_email_fuzzy), 'i');
430
+ re.email_fuzzy_global = RegExp(untpl(re.tpl_email_fuzzy), 'ig');
431
+ re.link_fuzzy = RegExp(untpl(re.tpl_link_fuzzy), 'i');
432
+ re.link_fuzzy_global = RegExp(untpl(re.tpl_link_fuzzy), 'ig');
457
433
  re.link_no_ip_fuzzy = RegExp(untpl(re.tpl_link_no_ip_fuzzy), 'i');
458
- re.host_fuzzy_test = RegExp(untpl(re.tpl_host_fuzzy_test), 'i');
434
+ re.link_no_ip_fuzzy_global = RegExp(untpl(re.tpl_link_no_ip_fuzzy), 'ig');
435
+ re.host_fuzzy_test = RegExp(untpl(re.tpl_host_fuzzy_test), 'i');
459
436
 
460
437
  //
461
438
  // Compile each schema
462
439
  //
463
440
 
464
- var aliases = [];
441
+ const aliases = [];
465
442
 
466
443
  self.__compiled__ = {}; // Reset compiled data
467
444
 
468
- function schemaError(name, val) {
469
- throw new Error('(LinkifyIt) Invalid schema "' + name + '": ' + val);
445
+ function schemaError (name, val) {
446
+ throw new Error(`(LinkifyIt) Invalid schema "${name}": ${val}`)
470
447
  }
471
448
 
472
449
  Object.keys(self.__schemas__).forEach(function (name) {
473
- var val = self.__schemas__[name];
450
+ const val = self.__schemas__[name];
474
451
 
475
452
  // skip disabled methods
476
- if (val === null) { return; }
453
+ if (val === null) { return }
477
454
 
478
- var compiled = { validate: null, link: null };
455
+ const compiled = { validate: null, link: null };
479
456
 
480
457
  self.__compiled__[name] = compiled;
481
458
 
@@ -496,12 +473,12 @@ function compile(self) {
496
473
  schemaError(name, val);
497
474
  }
498
475
 
499
- return;
476
+ return
500
477
  }
501
478
 
502
479
  if (isString(val)) {
503
480
  aliases.push(name);
504
- return;
481
+ return
505
482
  }
506
483
 
507
484
  schemaError(name, val);
@@ -515,7 +492,7 @@ function compile(self) {
515
492
  if (!self.__compiled__[self.__schemas__[alias]]) {
516
493
  // Silently fail on missed schemas to avoid errons on disable.
517
494
  // schemaError(alias, self.__schemas__[alias]);
518
- return;
495
+ return
519
496
  }
520
497
 
521
498
  self.__compiled__[alias].validate =
@@ -532,27 +509,22 @@ function compile(self) {
532
509
  //
533
510
  // Build schema condition
534
511
  //
535
- var slist = Object.keys(self.__compiled__)
536
- .filter(function (name) {
537
- // Filter disabled & fake schemas
538
- return name.length > 0 && self.__compiled__[name];
539
- })
540
- .map(escapeRE)
541
- .join('|');
512
+ const slist = Object.keys(self.__compiled__)
513
+ .filter(function (name) {
514
+ // Filter disabled & fake schemas
515
+ return name.length > 0 && self.__compiled__[name]
516
+ })
517
+ .map(escapeRE)
518
+ .join('|');
542
519
  // (?!_) cause 1.5x slowdown
543
- self.re.schema_test = RegExp('(^|(?!_)(?:[><\uff5c]|' + re.src_ZPCc + '))(' + slist + ')', 'i');
544
- self.re.schema_search = RegExp('(^|(?!_)(?:[><\uff5c]|' + re.src_ZPCc + '))(' + slist + ')', 'ig');
520
+ self.re.schema_test = RegExp(`(^|(?!_)(?:[><\uff5c]|${re.src_ZPCc}))(${slist})`, 'i');
521
+ self.re.schema_search = RegExp(`(^|(?!_)(?:[><\uff5c]|${re.src_ZPCc}))(${slist})`, 'ig');
522
+ self.re.schema_at_start = RegExp(`^${self.re.schema_search.source}`, 'i');
545
523
 
546
524
  self.re.pretest = RegExp(
547
- '(' + self.re.schema_test.source + ')|(' + self.re.host_fuzzy_test.source + ')|@',
525
+ `(${self.re.schema_test.source})|(${self.re.host_fuzzy_test.source})|@`,
548
526
  'i'
549
527
  );
550
-
551
- //
552
- // Cleanup
553
- //
554
-
555
- resetScanCache(self);
556
528
  }
557
529
 
558
530
  /**
@@ -560,58 +532,47 @@ function compile(self) {
560
532
  *
561
533
  * Match result. Single element of array, returned by [[LinkifyIt#match]]
562
534
  **/
563
- function Match(self, shift) {
564
- var start = self.__index__,
565
- end = self.__last_index__,
566
- text = self.__text_cache__.slice(start, end);
535
+ function Match (text, schema, index, lastIndex) {
536
+ const raw = text.slice(index, lastIndex);
567
537
 
568
538
  /**
569
539
  * Match#schema -> String
570
540
  *
571
541
  * Prefix (protocol) for matched string.
572
542
  **/
573
- this.schema = self.__schema__.toLowerCase();
543
+ this.schema = schema.toLowerCase();
574
544
  /**
575
545
  * Match#index -> Number
576
546
  *
577
547
  * First position of matched string.
578
548
  **/
579
- this.index = start + shift;
549
+ this.index = index;
580
550
  /**
581
551
  * Match#lastIndex -> Number
582
552
  *
583
553
  * Next position after matched string.
584
554
  **/
585
- this.lastIndex = end + shift;
555
+ this.lastIndex = lastIndex;
586
556
  /**
587
557
  * Match#raw -> String
588
558
  *
589
559
  * Matched string.
590
560
  **/
591
- this.raw = text;
561
+ this.raw = raw;
592
562
  /**
593
563
  * Match#text -> String
594
564
  *
595
565
  * Notmalized text of matched string.
596
566
  **/
597
- this.text = text;
567
+ this.text = raw;
598
568
  /**
599
569
  * Match#url -> String
600
570
  *
601
571
  * Normalized url of matched string.
602
572
  **/
603
- this.url = text;
604
- }
605
-
606
- function createMatch(self, shift) {
607
- var match = new Match(self, shift);
608
-
609
- self.__compiled__[match.schema].normalize(match, self);
610
-
611
- return match;
573
+ this.url = raw;
612
574
  }
613
575
 
614
-
615
576
  /**
616
577
  * class LinkifyIt
617
578
  **/
@@ -650,9 +611,9 @@ function createMatch(self, shift) {
650
611
  * - __fuzzyEmail__ - recognize emails without `mailto:` prefix.
651
612
  *
652
613
  **/
653
- function LinkifyIt(schemas, options) {
614
+ function LinkifyIt (schemas, options) {
654
615
  if (!(this instanceof LinkifyIt)) {
655
- return new LinkifyIt(schemas, options);
616
+ return new LinkifyIt(schemas, options)
656
617
  }
657
618
 
658
619
  if (!options) {
@@ -662,26 +623,19 @@ function LinkifyIt(schemas, options) {
662
623
  }
663
624
  }
664
625
 
665
- this.__opts__ = assign({}, defaultOptions, options);
666
-
667
- // Cache last tested result. Used to skip repeating steps on next `match` call.
668
- this.__index__ = -1;
669
- this.__last_index__ = -1; // Next scan position
670
- this.__schema__ = '';
671
- this.__text_cache__ = '';
626
+ this.__opts__ = assign({}, defaultOptions, options);
672
627
 
673
- this.__schemas__ = assign({}, defaultSchemas, schemas);
674
- this.__compiled__ = {};
628
+ this.__schemas__ = assign({}, defaultSchemas, schemas);
629
+ this.__compiled__ = {};
675
630
 
676
- this.__tlds__ = tlds_default;
677
- this.__tlds_replaced__ = false;
631
+ this.__tlds__ = tlds_default;
632
+ this.__tlds_replaced__ = false;
678
633
 
679
634
  this.re = {};
680
635
 
681
636
  compile(this);
682
637
  }
683
638
 
684
-
685
639
  /** chainable
686
640
  * LinkifyIt#add(schema, definition)
687
641
  * - schema (String): rule name (fixed pattern prefix)
@@ -689,99 +643,63 @@ function LinkifyIt(schemas, options) {
689
643
  *
690
644
  * Add new rule definition. See constructor description for details.
691
645
  **/
692
- LinkifyIt.prototype.add = function add(schema, definition) {
646
+ LinkifyIt.prototype.add = function add (schema, definition) {
693
647
  this.__schemas__[schema] = definition;
694
648
  compile(this);
695
- return this;
649
+ return this
696
650
  };
697
651
 
698
-
699
652
  /** chainable
700
653
  * LinkifyIt#set(options)
701
654
  * - options (Object): { fuzzyLink|fuzzyEmail|fuzzyIP: true|false }
702
655
  *
703
656
  * Set recognition options for links without schema.
704
657
  **/
705
- LinkifyIt.prototype.set = function set(options) {
658
+ LinkifyIt.prototype.set = function set (options) {
706
659
  this.__opts__ = assign(this.__opts__, options);
707
- return this;
660
+ return this
708
661
  };
709
662
 
710
-
711
663
  /**
712
664
  * LinkifyIt#test(text) -> Boolean
713
665
  *
714
666
  * Searches linkifiable pattern and returns `true` on success or `false` on fail.
715
667
  **/
716
- LinkifyIt.prototype.test = function test(text) {
717
- // Reset scan cache
718
- this.__text_cache__ = text;
719
- this.__index__ = -1;
720
-
721
- if (!text.length) { return false; }
668
+ LinkifyIt.prototype.test = function test (text) {
669
+ if (!text.length) { return false }
722
670
 
723
- var m, ml, me, len, shift, next, re, tld_pos, at_pos;
671
+ let m, re;
724
672
 
725
673
  // try to scan for link with schema - that's the most simple rule
726
674
  if (this.re.schema_test.test(text)) {
727
675
  re = this.re.schema_search;
728
676
  re.lastIndex = 0;
729
677
  while ((m = re.exec(text)) !== null) {
730
- len = this.testSchemaAt(text, m[2], re.lastIndex);
731
- if (len) {
732
- this.__schema__ = m[2];
733
- this.__index__ = m.index + m[1].length;
734
- this.__last_index__ = m.index + m[0].length + len;
735
- break;
736
- }
678
+ if (this.testSchemaAt(text, m[2], re.lastIndex)) { return true }
737
679
  }
738
680
  }
739
681
 
740
682
  if (this.__opts__.fuzzyLink && this.__compiled__['http:']) {
741
683
  // guess schemaless links
742
- tld_pos = text.search(this.re.host_fuzzy_test);
743
- if (tld_pos >= 0) {
744
- // if tld is located after found link - no need to check fuzzy pattern
745
- if (this.__index__ < 0 || tld_pos < this.__index__) {
746
- if ((ml = text.match(this.__opts__.fuzzyIP ? this.re.link_fuzzy : this.re.link_no_ip_fuzzy)) !== null) {
747
-
748
- shift = ml.index + ml[1].length;
749
-
750
- if (this.__index__ < 0 || shift < this.__index__) {
751
- this.__schema__ = '';
752
- this.__index__ = shift;
753
- this.__last_index__ = ml.index + ml[0].length;
754
- }
755
- }
684
+ if (text.search(this.re.host_fuzzy_test) >= 0) {
685
+ if (text.match(this.__opts__.fuzzyIP ? this.re.link_fuzzy : this.re.link_no_ip_fuzzy) !== null) {
686
+ return true
756
687
  }
757
688
  }
758
689
  }
759
690
 
760
691
  if (this.__opts__.fuzzyEmail && this.__compiled__['mailto:']) {
761
692
  // guess schemaless emails
762
- at_pos = text.indexOf('@');
763
- if (at_pos >= 0) {
693
+ if (text.indexOf('@') >= 0) {
764
694
  // We can't skip this check, because this cases are possible:
765
695
  // 192.168.1.1@gmail.com, my.in@example.com
766
- if ((me = text.match(this.re.email_fuzzy)) !== null) {
767
-
768
- shift = me.index + me[1].length;
769
- next = me.index + me[0].length;
770
-
771
- if (this.__index__ < 0 || shift < this.__index__ ||
772
- (shift === this.__index__ && next > this.__last_index__)) {
773
- this.__schema__ = 'mailto:';
774
- this.__index__ = shift;
775
- this.__last_index__ = next;
776
- }
777
- }
696
+ if (text.match(this.re.email_fuzzy) !== null) { return true }
778
697
  }
779
698
  }
780
699
 
781
- return this.__index__ >= 0;
700
+ return false
782
701
  };
783
702
 
784
-
785
703
  /**
786
704
  * LinkifyIt#pretest(text) -> Boolean
787
705
  *
@@ -789,11 +707,10 @@ LinkifyIt.prototype.test = function test(text) {
789
707
  * can exists. Can be used for speed optimization, when you need to check that
790
708
  * link NOT exists.
791
709
  **/
792
- LinkifyIt.prototype.pretest = function pretest(text) {
793
- return this.re.pretest.test(text);
710
+ LinkifyIt.prototype.pretest = function pretest (text) {
711
+ return this.re.pretest.test(text)
794
712
  };
795
713
 
796
-
797
714
  /**
798
715
  * LinkifyIt#testSchemaAt(text, name, position) -> Number
799
716
  * - text (String): text to scan
@@ -803,15 +720,14 @@ LinkifyIt.prototype.pretest = function pretest(text) {
803
720
  * Similar to [[LinkifyIt#test]] but checks only specific protocol tail exactly
804
721
  * at given position. Returns length of found pattern (0 on fail).
805
722
  **/
806
- LinkifyIt.prototype.testSchemaAt = function testSchemaAt(text, schema, pos) {
723
+ LinkifyIt.prototype.testSchemaAt = function testSchemaAt (text, schema, pos) {
807
724
  // If not supported schema check requested - terminate
808
725
  if (!this.__compiled__[schema.toLowerCase()]) {
809
- return 0;
726
+ return 0
810
727
  }
811
- return this.__compiled__[schema.toLowerCase()].validate(text, pos, this);
728
+ return this.__compiled__[schema.toLowerCase()].validate(text, pos, this)
812
729
  };
813
730
 
814
-
815
731
  /**
816
732
  * LinkifyIt#match(text) -> Array|null
817
733
  *
@@ -828,33 +744,119 @@ LinkifyIt.prototype.testSchemaAt = function testSchemaAt(text, schema, pos) {
828
744
  * - __text__ - normalized text
829
745
  * - __url__ - link, generated from matched text
830
746
  **/
831
- LinkifyIt.prototype.match = function match(text) {
832
- var shift = 0, result = [];
747
+ LinkifyIt.prototype.match = function match (text) {
748
+ const result = [];
749
+ const type_schemed = [];
750
+ const type_fuzzy_link = [];
751
+ const type_fuzzy_email = [];
752
+ let m, len, re;
753
+
754
+ function choose (a, b) {
755
+ if (!a) { return b }
756
+ if (!b) { return a }
757
+ if (a.index !== b.index) { return a.index < b.index ? a : b }
758
+ return a.lastIndex >= b.lastIndex ? a : b
759
+ }
833
760
 
834
- // Try to take previous element from cache, if .test() called before
835
- if (this.__index__ >= 0 && this.__text_cache__ === text) {
836
- result.push(createMatch(this, shift));
837
- shift = this.__last_index__;
761
+ if (!text.length) { return null }
762
+
763
+ // scan for links with schema
764
+ if (this.re.schema_test.test(text)) {
765
+ re = this.re.schema_search;
766
+ re.lastIndex = 0;
767
+ while ((m = re.exec(text)) !== null) {
768
+ len = this.testSchemaAt(text, m[2], re.lastIndex);
769
+ if (len) {
770
+ type_schemed.push({
771
+ schema: m[2],
772
+ index: m.index + m[1].length,
773
+ lastIndex: m.index + m[0].length + len
774
+ });
775
+ }
776
+ }
838
777
  }
839
778
 
840
- // Cut head if cache was used
841
- var tail = shift ? text.slice(shift) : text;
779
+ if (this.__opts__.fuzzyLink && this.__compiled__['http:']) {
780
+ re = this.__opts__.fuzzyIP ? this.re.link_fuzzy_global : this.re.link_no_ip_fuzzy_global;
781
+ re.lastIndex = 0;
782
+ while ((m = re.exec(text)) !== null) {
783
+ type_fuzzy_link.push({
784
+ schema: '',
785
+ index: m.index + m[1].length,
786
+ lastIndex: m.index + m[0].length
787
+ });
788
+ }
789
+ }
842
790
 
843
- // Scan string until end reached
844
- while (this.test(tail)) {
845
- result.push(createMatch(this, shift));
791
+ if (this.__opts__.fuzzyEmail && this.__compiled__['mailto:']) {
792
+ re = this.re.email_fuzzy_global;
793
+ re.lastIndex = 0;
794
+ while ((m = re.exec(text)) !== null) {
795
+ type_fuzzy_email.push({
796
+ schema: 'mailto:',
797
+ index: m.index + m[1].length,
798
+ lastIndex: m.index + m[0].length
799
+ });
800
+ }
801
+ }
802
+
803
+ const indexes = [0, 0, 0];
804
+ let lastIndex = 0;
805
+
806
+ for (;;) {
807
+ const candidates = [
808
+ type_schemed[indexes[0]],
809
+ type_fuzzy_email[indexes[1]],
810
+ type_fuzzy_link[indexes[2]]
811
+ ];
812
+
813
+ const candidate = choose(choose(candidates[0], candidates[1]), candidates[2]);
814
+
815
+ if (!candidate) { break }
816
+
817
+ if (candidate === candidates[0]) {
818
+ indexes[0]++;
819
+ } else if (candidate === candidates[1]) {
820
+ indexes[1]++;
821
+ } else {
822
+ indexes[2]++;
823
+ }
824
+
825
+ if (candidate.index < lastIndex) { continue }
846
826
 
847
- tail = tail.slice(this.__last_index__);
848
- shift += this.__last_index__;
827
+ const match = new Match(text, candidate.schema, candidate.index, candidate.lastIndex);
828
+ this.__compiled__[match.schema].normalize(match, this);
829
+ result.push(match);
830
+ lastIndex = candidate.lastIndex;
849
831
  }
850
832
 
851
833
  if (result.length) {
852
- return result;
834
+ return result
853
835
  }
854
836
 
855
- return null;
837
+ return null
856
838
  };
857
839
 
840
+ /**
841
+ * LinkifyIt#matchAtStart(text) -> Match|null
842
+ *
843
+ * Returns fully-formed (not fuzzy) link if it starts at the beginning
844
+ * of the string, and null otherwise.
845
+ **/
846
+ LinkifyIt.prototype.matchAtStart = function matchAtStart (text) {
847
+ if (!text.length) return null
848
+
849
+ const m = this.re.schema_at_start.exec(text);
850
+ if (!m) return null
851
+
852
+ const len = this.testSchemaAt(text, m[2], m[0].length);
853
+ if (!len) return null
854
+
855
+ const match = new Match(text, m[2], m.index + m[1].length, m.index + m[0].length + len);
856
+
857
+ this.__compiled__[match.schema].normalize(match, this);
858
+ return match
859
+ };
858
860
 
859
861
  /** chainable
860
862
  * LinkifyIt#tlds(list [, keepOld]) -> this
@@ -871,25 +873,25 @@ LinkifyIt.prototype.match = function match(text) {
871
873
  *
872
874
  * If list is replaced, then exact match for 2-chars root zones will be checked.
873
875
  **/
874
- LinkifyIt.prototype.tlds = function tlds(list, keepOld) {
875
- list = Array.isArray(list) ? list : [ list ];
876
+ LinkifyIt.prototype.tlds = function tlds (list, keepOld) {
877
+ list = Array.isArray(list) ? list : [list];
876
878
 
877
879
  if (!keepOld) {
878
880
  this.__tlds__ = list.slice();
879
881
  this.__tlds_replaced__ = true;
880
882
  compile(this);
881
- return this;
883
+ return this
882
884
  }
883
885
 
884
886
  this.__tlds__ = this.__tlds__.concat(list)
885
- .sort()
886
- .filter(function (el, idx, arr) {
887
- return el !== arr[idx - 1];
888
- })
889
- .reverse();
887
+ .sort()
888
+ .filter(function (el, idx, arr) {
889
+ return el !== arr[idx - 1]
890
+ })
891
+ .reverse();
890
892
 
891
893
  compile(this);
892
- return this;
894
+ return this
893
895
  };
894
896
 
895
897
  /**
@@ -897,29 +899,26 @@ LinkifyIt.prototype.tlds = function tlds(list, keepOld) {
897
899
  *
898
900
  * Default normalizer (if schema does not define it's own).
899
901
  **/
900
- LinkifyIt.prototype.normalize = function normalize(match) {
901
-
902
+ LinkifyIt.prototype.normalize = function normalize (match) {
902
903
  // Do minimal possible changes by default. Need to collect feedback prior
903
904
  // to move forward https://github.com/markdown-it/linkify-it/issues/1
904
905
 
905
- if (!match.schema) { match.url = 'http://' + match.url; }
906
+ if (!match.schema) { match.url = `http://${match.url}`; }
906
907
 
907
908
  if (match.schema === 'mailto:' && !/^mailto:/i.test(match.url)) {
908
- match.url = 'mailto:' + match.url;
909
+ match.url = `mailto:${match.url}`;
909
910
  }
910
911
  };
911
912
 
912
-
913
913
  /**
914
914
  * LinkifyIt#onCompile()
915
915
  *
916
916
  * Override to modify basic RegExp-s.
917
917
  **/
918
- LinkifyIt.prototype.onCompile = function onCompile() {
918
+ LinkifyIt.prototype.onCompile = function onCompile () {
919
919
  };
920
920
 
921
-
922
- var linkifyIt = LinkifyIt;
921
+ var index_cjs = LinkifyIt;
923
922
 
924
923
  var require$$1 = [
925
924
  "aaa",
@@ -2386,7 +2385,7 @@ Object.defineProperty(defaultMatchDecorator, "__esModule", {
2386
2385
  value: true
2387
2386
  });
2388
2387
 
2389
- var _linkifyIt = linkifyIt;
2388
+ var _linkifyIt = index_cjs;
2390
2389
 
2391
2390
  var _linkifyIt2 = _interopRequireDefault$2(_linkifyIt);
2392
2391