@bigbinary/neeto-form-frontend 4.4.58 → 4.4.59-beta1
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/.ready +1 -1
- package/dist/BuildForm.js +1 -1
- package/dist/ExternalForm.js +2 -2
- package/dist/Submission.js +383 -384
- package/dist/Submission.js.map +1 -1
- package/dist/UrlBuilder.js +2 -2
- package/dist/cjs/BuildForm.js +1 -1
- package/dist/cjs/ExternalForm.js +2 -2
- package/dist/cjs/Submission.js +383 -384
- package/dist/cjs/Submission.js.map +1 -1
- package/dist/cjs/UrlBuilder.js +2 -2
- package/dist/cjs/index.js +2 -2
- package/dist/cjs/{utils-zVNwUbdx.js → utils-BpyTbv4T.js} +2 -2
- package/dist/cjs/{utils-zVNwUbdx.js.map → utils-BpyTbv4T.js.map} +1 -1
- package/dist/cjs/v2/BuildForm.js +1 -1
- package/dist/cjs/v2/ExternalForm.js +2 -2
- package/dist/cjs/v2/Submission.js +383 -384
- package/dist/cjs/v2/Submission.js.map +1 -1
- package/dist/cjs/v2/UrlBuilder.js +2 -2
- package/dist/cjs/v2/index.js +2 -2
- package/dist/cjs/v2/{utils-CjowRPXH.js → utils-BEmzx_CT.js} +2 -2
- package/dist/cjs/v2/{utils-CjowRPXH.js.map → utils-BEmzx_CT.js.map} +1 -1
- package/dist/cjs/v2/{yup-DSCAoUTF.js → yup-BJdUP8f6.js} +12 -12
- package/dist/cjs/v2/{yup-DSCAoUTF.js.map → yup-BJdUP8f6.js.map} +1 -1
- package/dist/cjs/{yup-BPzvBMfE.js → yup-C1tUTQs0.js} +12 -12
- package/dist/cjs/{yup-BPzvBMfE.js.map → yup-C1tUTQs0.js.map} +1 -1
- package/dist/index.js +2 -2
- package/dist/{utils-CMGhbRpZ.js → utils-DwvyMha8.js} +2 -2
- package/dist/{utils-CMGhbRpZ.js.map → utils-DwvyMha8.js.map} +1 -1
- package/dist/v2/BuildForm.js +1 -1
- package/dist/v2/ExternalForm.js +2 -2
- package/dist/v2/Submission.js +383 -384
- package/dist/v2/Submission.js.map +1 -1
- package/dist/v2/UrlBuilder.js +2 -2
- package/dist/v2/index.js +2 -2
- package/dist/v2/{utils-UvAB6bbG.js → utils-Dng9m1z9.js} +2 -2
- package/dist/v2/{utils-UvAB6bbG.js.map → utils-Dng9m1z9.js.map} +1 -1
- package/dist/v2/{yup-BaiHo-7Z.js → yup-hYIKNz1B.js} +12 -12
- package/dist/v2/{yup-BaiHo-7Z.js.map → yup-hYIKNz1B.js.map} +1 -1
- package/dist/{yup-CzoKyYgO.js → yup-TxS0SXvr.js} +12 -12
- package/dist/{yup-CzoKyYgO.js.map → yup-TxS0SXvr.js.map} +1 -1
- package/package.json +4 -4
|
@@ -63,309 +63,295 @@ defaultHrefDecorator.default = function (href) {
|
|
|
63
63
|
|
|
64
64
|
var defaultMatchDecorator = {};
|
|
65
65
|
|
|
66
|
-
var
|
|
67
|
-
var hasRequiredRegex$3;
|
|
68
|
-
|
|
69
|
-
function requireRegex$3 () {
|
|
70
|
-
if (hasRequiredRegex$3) return regex$3;
|
|
71
|
-
hasRequiredRegex$3 = 1;
|
|
72
|
-
regex$3=/[\0-\uD7FF\uE000-\uFFFF]|[\uD800-\uDBFF][\uDC00-\uDFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF]/;
|
|
73
|
-
return regex$3;
|
|
74
|
-
}
|
|
66
|
+
var index_cjs$1 = {};
|
|
75
67
|
|
|
76
|
-
var regex$
|
|
77
|
-
var hasRequiredRegex$2;
|
|
68
|
+
var regex$5 = /[\0-\uD7FF\uE000-\uFFFF]|[\uD800-\uDBFF][\uDC00-\uDFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF]/;
|
|
78
69
|
|
|
79
|
-
|
|
80
|
-
if (hasRequiredRegex$2) return regex$2;
|
|
81
|
-
hasRequiredRegex$2 = 1;
|
|
82
|
-
regex$2=/[\0-\x1F\x7F-\x9F]/;
|
|
83
|
-
return regex$2;
|
|
84
|
-
}
|
|
70
|
+
var regex$4 = /[\0-\x1F\x7F-\x9F]/;
|
|
85
71
|
|
|
86
|
-
var regex$
|
|
87
|
-
var hasRequiredRegex$1;
|
|
72
|
+
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]/;
|
|
88
73
|
|
|
89
|
-
|
|
90
|
-
if (hasRequiredRegex$1) return regex$1;
|
|
91
|
-
hasRequiredRegex$1 = 1;
|
|
92
|
-
regex$1=/[ \xA0\u1680\u2000-\u200A\u2028\u2029\u202F\u205F\u3000]/;
|
|
93
|
-
return regex$1;
|
|
94
|
-
}
|
|
74
|
+
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]/;
|
|
95
75
|
|
|
96
|
-
var regex
|
|
97
|
-
var hasRequiredRegex;
|
|
76
|
+
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]/;
|
|
98
77
|
|
|
99
|
-
|
|
100
|
-
if (hasRequiredRegex) return regex;
|
|
101
|
-
hasRequiredRegex = 1;
|
|
102
|
-
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]/;
|
|
103
|
-
return regex;
|
|
104
|
-
}
|
|
78
|
+
var regex = /[ \xA0\u1680\u2000-\u200A\u2028\u2029\u202F\u205F\u3000]/;
|
|
105
79
|
|
|
106
|
-
|
|
107
|
-
|
|
80
|
+
index_cjs$1.Any = regex$5;
|
|
81
|
+
index_cjs$1.Cc = regex$4;
|
|
82
|
+
index_cjs$1.Cf = regex$3;
|
|
83
|
+
index_cjs$1.P = regex$2;
|
|
84
|
+
index_cjs$1.S = regex$1;
|
|
85
|
+
index_cjs$1.Z = regex;
|
|
108
86
|
|
|
109
|
-
|
|
110
|
-
if (hasRequiredRe) return re;
|
|
111
|
-
hasRequiredRe = 1;
|
|
87
|
+
var uc_micro = index_cjs$1;
|
|
112
88
|
|
|
89
|
+
function reFactory (opts) {
|
|
90
|
+
const re = {};
|
|
91
|
+
opts = opts || {};
|
|
113
92
|
|
|
114
|
-
|
|
115
|
-
|
|
93
|
+
re.src_Any = uc_micro.Any.source;
|
|
94
|
+
re.src_Cc = uc_micro.Cc.source;
|
|
95
|
+
re.src_Z = uc_micro.Z.source;
|
|
96
|
+
re.src_P = uc_micro.P.source;
|
|
116
97
|
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
re.src_Cc = requireRegex$2().source;
|
|
120
|
-
re.src_Z = requireRegex$1().source;
|
|
121
|
-
re.src_P = requireRegex().source;
|
|
98
|
+
// \p{\Z\P\Cc\CF} (white spaces + control + format + punctuation)
|
|
99
|
+
re.src_ZPCc = [re.src_Z, re.src_P, re.src_Cc].join('|');
|
|
122
100
|
|
|
123
|
-
|
|
124
|
-
|
|
101
|
+
// \p{\Z\Cc} (white spaces + control)
|
|
102
|
+
re.src_ZCc = [re.src_Z, re.src_Cc].join('|');
|
|
125
103
|
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
// Experimental. List of chars, completely prohibited in links
|
|
130
|
-
// because can separate it from other part of text
|
|
131
|
-
var text_separators = '[><\uff5c]';
|
|
104
|
+
// Experimental. List of chars, completely prohibited in links
|
|
105
|
+
// because can separate it from other part of text
|
|
106
|
+
const text_separators = '[><\uff5c]';
|
|
132
107
|
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
108
|
+
// All possible word characters (everything without punctuation, spaces & controls)
|
|
109
|
+
// Defined via punctuation & spaces to save space
|
|
110
|
+
// Should be something like \p{\L\N\S\M} (\w but without `_`)
|
|
111
|
+
re.src_pseudo_letter = `(?:(?!${text_separators}|${re.src_ZPCc})${re.src_Any})`;
|
|
112
|
+
// The same as abothe but without [0-9]
|
|
113
|
+
// var src_pseudo_letter_non_d = '(?:(?![0-9]|' + src_ZPCc + ')' + src_Any + ')';
|
|
139
114
|
|
|
140
|
-
|
|
115
|
+
re.src_ip4 =
|
|
141
116
|
|
|
142
|
-
|
|
117
|
+
'(?:(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]?)';
|
|
143
118
|
|
|
144
|
-
|
|
119
|
+
// Prohibit any of "@/[]()" in user/pass to avoid wrong domain fetch.
|
|
120
|
+
// Length is capped to exclude possible rescans till the end and avoid O(n^2)
|
|
121
|
+
// DoS. No standard limit, just take something reasonable.
|
|
122
|
+
re.src_auth = `(?:(?:(?!${re.src_ZCc}|[@/\\[\\]()]).){1,50}@)?`;
|
|
145
123
|
|
|
146
|
-
|
|
147
|
-
re.src_auth = '(?:(?:(?!' + re.src_ZCc + '|[@/\\[\\]()]).)+@)?';
|
|
124
|
+
re.src_port =
|
|
148
125
|
|
|
149
|
-
|
|
126
|
+
'(?::(?:6(?:[0-4]\\d{3}|5(?:[0-4]\\d{2}|5(?:[0-2]\\d|3[0-5])))|[1-5]?\\d{1,4}))?';
|
|
150
127
|
|
|
151
|
-
|
|
128
|
+
re.src_host_terminator =
|
|
152
129
|
|
|
153
|
-
|
|
130
|
+
`(?=$|${text_separators}|${re.src_ZPCc})` +
|
|
131
|
+
`(?!${opts['---'] ? '-(?!--)|' : '-|'}_|:\\d|\\.-|\\.(?!$|${re.src_ZPCc}))`;
|
|
154
132
|
|
|
155
|
-
|
|
133
|
+
re.src_path =
|
|
156
134
|
|
|
157
|
-
|
|
135
|
+
'(?:' +
|
|
136
|
+
'[/?#]' +
|
|
137
|
+
'(?:' +
|
|
138
|
+
`(?!${re.src_ZCc}|${text_separators}|[()[\\]{}.,"'?!\\-;]).|` +
|
|
139
|
+
`\\[(?:(?!${re.src_ZCc}|\\]).)*\\]|` +
|
|
140
|
+
`\\((?:(?!${re.src_ZCc}|[)]).)*\\)|` +
|
|
141
|
+
`\\{(?:(?!${re.src_ZCc}|[}]).)*\\}|` +
|
|
142
|
+
`\\"(?:(?!${re.src_ZCc}|["]).)+\\"|` +
|
|
143
|
+
`\\'(?:(?!${re.src_ZCc}|[']).)+\\'|` +
|
|
158
144
|
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
'(?:' +
|
|
162
|
-
'(?!' + re.src_ZCc + '|' + text_separators + '|[()[\\]{}.,"\'?!\\-]).|' +
|
|
163
|
-
'\\[(?:(?!' + re.src_ZCc + '|\\]).)*\\]|' +
|
|
164
|
-
'\\((?:(?!' + re.src_ZCc + '|[)]).)*\\)|' +
|
|
165
|
-
'\\{(?:(?!' + re.src_ZCc + '|[}]).)*\\}|' +
|
|
166
|
-
'\\"(?:(?!' + re.src_ZCc + '|["]).)+\\"|' +
|
|
167
|
-
"\\'(?:(?!" + re.src_ZCc + "|[']).)+\\'|" +
|
|
168
|
-
"\\'(?=" + re.src_pseudo_letter + '|[-]).|' + // allow `I'm_king` if no pair found
|
|
169
|
-
'\\.{2,4}[a-zA-Z0-9%/]|' + // github has ... in commit range links,
|
|
170
|
-
// google has .... in links (issue #66)
|
|
171
|
-
// Restrict to
|
|
172
|
-
// - english
|
|
173
|
-
// - percent-encoded
|
|
174
|
-
// - parts of file path
|
|
175
|
-
// until more examples found.
|
|
176
|
-
'\\.(?!' + re.src_ZCc + '|[.]).|' +
|
|
177
|
-
(opts && opts['---'] ?
|
|
178
|
-
'\\-(?!--(?:[^-]|$))(?:-*)|' // `---` => long dash, terminate
|
|
179
|
-
:
|
|
180
|
-
'\\-+|'
|
|
181
|
-
) +
|
|
182
|
-
'\\,(?!' + re.src_ZCc + ').|' + // allow `,,,` in paths
|
|
183
|
-
'\\!(?!' + re.src_ZCc + '|[!]).|' +
|
|
184
|
-
'\\?(?!' + re.src_ZCc + '|[?]).' +
|
|
185
|
-
')+' +
|
|
186
|
-
'|\\/' +
|
|
187
|
-
')?';
|
|
145
|
+
// allow `I'm_king` if no pair found
|
|
146
|
+
`\\'(?=${re.src_pseudo_letter}|[-])|` +
|
|
188
147
|
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
148
|
+
// google has many dots in "google search" links (#66, #81).
|
|
149
|
+
// github has ... in commit range links,
|
|
150
|
+
// Restrict to
|
|
151
|
+
// - english
|
|
152
|
+
// - percent-encoded
|
|
153
|
+
// - parts of file path
|
|
154
|
+
// - params separator
|
|
155
|
+
// until more examples found.
|
|
156
|
+
'\\.{2,}[a-zA-Z0-9%/&]|' +
|
|
192
157
|
|
|
193
|
-
|
|
158
|
+
`\\.(?!${re.src_ZCc}|[.]|$)|` +
|
|
159
|
+
(opts['---']
|
|
160
|
+
? '\\-(?!--(?:[^-]|$))(?:-*)|' // `---` => long dash, terminate
|
|
161
|
+
: '\\-+|'
|
|
162
|
+
) +
|
|
163
|
+
// allow `,,,` in paths
|
|
164
|
+
`,(?!${re.src_ZCc}|$)|` +
|
|
194
165
|
|
|
195
|
-
|
|
166
|
+
// allow `;` if not followed by space-like char
|
|
167
|
+
`;(?!${re.src_ZCc}|$)|` +
|
|
196
168
|
|
|
197
|
-
|
|
169
|
+
// allow `!!!` in paths, but not at the end
|
|
170
|
+
`\\!+(?!${re.src_ZCc}|[!]|$)|` +
|
|
198
171
|
|
|
199
|
-
|
|
200
|
-
|
|
172
|
+
`\\?(?!${re.src_ZCc}|[?]|$)` +
|
|
173
|
+
')+' +
|
|
174
|
+
'|\\/' +
|
|
175
|
+
')?';
|
|
201
176
|
|
|
202
|
-
|
|
177
|
+
// Allow anything in markdown spec, forbid quote (") at the first position
|
|
178
|
+
// because emails enclosed in quotes are far more common
|
|
179
|
+
// Max name length capped to 64 chars (RFC 5321). This also prevents O(n^2)
|
|
180
|
+
// rescans to the end on inputs like `mailto:mailto:...`
|
|
181
|
+
re.src_email_name =
|
|
203
182
|
|
|
204
|
-
|
|
205
|
-
'(?:' +
|
|
206
|
-
re.src_xn +
|
|
207
|
-
'|' +
|
|
208
|
-
re.src_pseudo_letter + '{1,63}' +
|
|
209
|
-
')';
|
|
183
|
+
'[\\-;:&=\\+\\$,\\.a-zA-Z0-9_][\\-;:&=\\+\\$,\\"\\.a-zA-Z0-9_]{0,63}';
|
|
210
184
|
|
|
211
|
-
|
|
185
|
+
re.src_xn =
|
|
212
186
|
|
|
213
|
-
|
|
214
|
-
re.src_xn +
|
|
215
|
-
'|' +
|
|
216
|
-
'(?:' + re.src_pseudo_letter + ')' +
|
|
217
|
-
'|' +
|
|
218
|
-
'(?:' + re.src_pseudo_letter + '(?:-|' + re.src_pseudo_letter + '){0,61}' + re.src_pseudo_letter + ')' +
|
|
219
|
-
')';
|
|
187
|
+
'xn--[a-z0-9\\-]{1,59}';
|
|
220
188
|
|
|
221
|
-
|
|
189
|
+
// More to read about domain names
|
|
190
|
+
// http://serverfault.com/questions/638260/
|
|
222
191
|
|
|
223
|
-
|
|
224
|
-
// Don't need IP check, because digits are already allowed in normal domain names
|
|
225
|
-
// src_ip4 +
|
|
226
|
-
// '|' +
|
|
227
|
-
'(?:(?:(?:' + re.src_domain + ')\\.)*' + re.src_domain/*_root*/ + ')' +
|
|
228
|
-
')';
|
|
192
|
+
re.src_domain_root =
|
|
229
193
|
|
|
230
|
-
|
|
194
|
+
// Allow letters & digits (http://test1)
|
|
195
|
+
'(?:' +
|
|
196
|
+
re.src_xn +
|
|
197
|
+
'|' +
|
|
198
|
+
`${re.src_pseudo_letter}{1,63}` +
|
|
199
|
+
')';
|
|
231
200
|
|
|
232
|
-
|
|
233
|
-
re.src_ip4 +
|
|
234
|
-
'|' +
|
|
235
|
-
'(?:(?:(?:' + re.src_domain + ')\\.)+(?:%TLDS%))' +
|
|
236
|
-
')';
|
|
201
|
+
re.src_domain =
|
|
237
202
|
|
|
238
|
-
|
|
203
|
+
'(?:' +
|
|
204
|
+
re.src_xn +
|
|
205
|
+
'|' +
|
|
206
|
+
`(?:${re.src_pseudo_letter})` +
|
|
207
|
+
'|' +
|
|
208
|
+
`(?:${re.src_pseudo_letter}(?:-|${re.src_pseudo_letter}){0,61}${re.src_pseudo_letter})` +
|
|
209
|
+
')';
|
|
239
210
|
|
|
240
|
-
|
|
211
|
+
re.src_host =
|
|
241
212
|
|
|
242
|
-
|
|
213
|
+
'(?:' +
|
|
214
|
+
// Don't need IP check, because digits are already allowed in normal domain names
|
|
215
|
+
// src_ip4 +
|
|
216
|
+
// '|' +
|
|
217
|
+
`(?:(?:(?:${re.src_domain})\\.)*${re.src_domain})`/* _root */ +
|
|
218
|
+
')';
|
|
243
219
|
|
|
244
|
-
|
|
220
|
+
re.tpl_host_fuzzy =
|
|
245
221
|
|
|
246
|
-
|
|
222
|
+
'(?:' +
|
|
223
|
+
re.src_ip4 +
|
|
224
|
+
'|' +
|
|
225
|
+
`(?:(?:(?:${re.src_domain})\\.)+(?:%TLDS%))` +
|
|
226
|
+
')';
|
|
247
227
|
|
|
248
|
-
|
|
228
|
+
re.tpl_host_no_ip_fuzzy =
|
|
249
229
|
|
|
250
|
-
|
|
230
|
+
`(?:(?:(?:${re.src_domain})\\.)+(?:%TLDS%))`;
|
|
251
231
|
|
|
252
|
-
|
|
232
|
+
re.src_host_strict =
|
|
253
233
|
|
|
254
|
-
|
|
234
|
+
re.src_host + re.src_host_terminator;
|
|
255
235
|
|
|
256
|
-
|
|
236
|
+
re.tpl_host_fuzzy_strict =
|
|
257
237
|
|
|
258
|
-
|
|
238
|
+
re.tpl_host_fuzzy + re.src_host_terminator;
|
|
259
239
|
|
|
260
|
-
|
|
240
|
+
re.src_host_port_strict =
|
|
261
241
|
|
|
242
|
+
re.src_host + re.src_port + re.src_host_terminator;
|
|
262
243
|
|
|
263
|
-
|
|
264
|
-
// Main rules
|
|
244
|
+
re.tpl_host_port_fuzzy_strict =
|
|
265
245
|
|
|
266
|
-
|
|
267
|
-
re.tpl_host_fuzzy_test =
|
|
246
|
+
re.tpl_host_fuzzy + re.src_port + re.src_host_terminator;
|
|
268
247
|
|
|
269
|
-
|
|
248
|
+
re.tpl_host_port_no_ip_fuzzy_strict =
|
|
270
249
|
|
|
271
|
-
|
|
250
|
+
re.tpl_host_no_ip_fuzzy + re.src_port + re.src_host_terminator;
|
|
251
|
+
|
|
252
|
+
//
|
|
253
|
+
// Main rules
|
|
254
|
+
//
|
|
272
255
|
|
|
273
|
-
|
|
274
|
-
|
|
256
|
+
// Rude test fuzzy links by host, for quick deny
|
|
257
|
+
re.tpl_host_fuzzy_test =
|
|
275
258
|
|
|
276
|
-
|
|
277
|
-
// Fuzzy link can't be prepended with .:/\- and non punctuation.
|
|
278
|
-
// but can start with > (markdown blockquote)
|
|
279
|
-
'(^|(?![.:/\\-_@])(?:[$+<=>^`|\uff5c]|' + re.src_ZPCc + '))' +
|
|
280
|
-
'((?![$+<=>^`|\uff5c])' + re.tpl_host_port_fuzzy_strict + re.src_path + ')';
|
|
259
|
+
`localhost|www\\.|\\.\\d{1,3}\\.|(?:\\.(?:%TLDS%)(?:${re.src_ZPCc}|>|$))`;
|
|
281
260
|
|
|
282
|
-
|
|
283
|
-
// Fuzzy link can't be prepended with .:/\- and non punctuation.
|
|
284
|
-
// but can start with > (markdown blockquote)
|
|
285
|
-
'(^|(?![.:/\\-_@])(?:[$+<=>^`|\uff5c]|' + re.src_ZPCc + '))' +
|
|
286
|
-
'((?![$+<=>^`|\uff5c])' + re.tpl_host_port_no_ip_fuzzy_strict + re.src_path + ')';
|
|
261
|
+
re.tpl_email_fuzzy =
|
|
287
262
|
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
263
|
+
`(^|${text_separators}|"|\\(|${re.src_ZCc})` +
|
|
264
|
+
`(${re.src_email_name}@${re.tpl_host_fuzzy_strict})`;
|
|
265
|
+
|
|
266
|
+
re.tpl_link_fuzzy =
|
|
267
|
+
// Fuzzy link can't be prepended with .:/\- and non punctuation.
|
|
268
|
+
// but can start with > (markdown blockquote)
|
|
269
|
+
`(^|(?![.:/\\-_@])(?:[$+<=>^\`|\uff5c]|${re.src_ZPCc}))` +
|
|
270
|
+
`((?![$+<=>^\`|\uff5c])${re.tpl_host_port_fuzzy_strict}${re.src_path})`;
|
|
271
|
+
|
|
272
|
+
re.tpl_link_no_ip_fuzzy =
|
|
273
|
+
// Fuzzy link can't be prepended with .:/\- and non punctuation.
|
|
274
|
+
// but can start with > (markdown blockquote)
|
|
275
|
+
`(^|(?![.:/\\-_@])(?:[$+<=>^\`|\uff5c]|${re.src_ZPCc}))` +
|
|
276
|
+
`((?![$+<=>^\`|\uff5c])${re.tpl_host_port_no_ip_fuzzy_strict}${re.src_path})`;
|
|
277
|
+
|
|
278
|
+
return re
|
|
291
279
|
}
|
|
292
280
|
|
|
293
|
-
|
|
281
|
+
//
|
|
294
282
|
// Helpers
|
|
283
|
+
//
|
|
295
284
|
|
|
296
285
|
// Merge objects
|
|
297
286
|
//
|
|
298
|
-
function assign(obj /*from1, from2, from3,
|
|
299
|
-
|
|
287
|
+
function assign (obj /* from1, from2, from3, ... */) {
|
|
288
|
+
const sources = Array.prototype.slice.call(arguments, 1);
|
|
300
289
|
|
|
301
290
|
sources.forEach(function (source) {
|
|
302
|
-
if (!source) { return
|
|
291
|
+
if (!source) { return }
|
|
303
292
|
|
|
304
293
|
Object.keys(source).forEach(function (key) {
|
|
305
294
|
obj[key] = source[key];
|
|
306
295
|
});
|
|
307
296
|
});
|
|
308
297
|
|
|
309
|
-
return obj
|
|
298
|
+
return obj
|
|
310
299
|
}
|
|
311
300
|
|
|
312
|
-
function _class(obj) { return Object.prototype.toString.call(obj)
|
|
313
|
-
function isString(obj) { return _class(obj) === '[object String]'
|
|
314
|
-
function isObject(obj) { return _class(obj) === '[object Object]'
|
|
315
|
-
function isRegExp(obj) { return _class(obj) === '[object RegExp]'
|
|
316
|
-
function isFunction(obj) { return _class(obj) === '[object Function]'
|
|
317
|
-
|
|
301
|
+
function _class (obj) { return Object.prototype.toString.call(obj) }
|
|
302
|
+
function isString (obj) { return _class(obj) === '[object String]' }
|
|
303
|
+
function isObject (obj) { return _class(obj) === '[object Object]' }
|
|
304
|
+
function isRegExp (obj) { return _class(obj) === '[object RegExp]' }
|
|
305
|
+
function isFunction (obj) { return _class(obj) === '[object Function]' }
|
|
318
306
|
|
|
319
|
-
function escapeRE(str) { return str.replace(/[.?*+^$[\]\\(){}|-]/g, '\\$&')
|
|
320
|
-
|
|
321
|
-
////////////////////////////////////////////////////////////////////////////////
|
|
307
|
+
function escapeRE (str) { return str.replace(/[.?*+^$[\]\\(){}|-]/g, '\\$&') }
|
|
322
308
|
|
|
309
|
+
//
|
|
323
310
|
|
|
324
|
-
|
|
311
|
+
const defaultOptions = {
|
|
325
312
|
fuzzyLink: true,
|
|
326
313
|
fuzzyEmail: true,
|
|
327
314
|
fuzzyIP: false
|
|
328
315
|
};
|
|
329
316
|
|
|
330
|
-
|
|
331
|
-
function isOptionsObj(obj) {
|
|
317
|
+
function isOptionsObj (obj) {
|
|
332
318
|
return Object.keys(obj || {}).reduce(function (acc, k) {
|
|
333
|
-
|
|
334
|
-
|
|
319
|
+
/* eslint-disable-next-line no-prototype-builtins */
|
|
320
|
+
return acc || defaultOptions.hasOwnProperty(k)
|
|
321
|
+
}, false)
|
|
335
322
|
}
|
|
336
323
|
|
|
337
|
-
|
|
338
|
-
var defaultSchemas = {
|
|
324
|
+
const defaultSchemas = {
|
|
339
325
|
'http:': {
|
|
340
326
|
validate: function (text, pos, self) {
|
|
341
|
-
|
|
327
|
+
const tail = text.slice(pos);
|
|
342
328
|
|
|
343
329
|
if (!self.re.http) {
|
|
344
330
|
// compile lazily, because "host"-containing variables can change on tlds update.
|
|
345
|
-
self.re.http =
|
|
346
|
-
|
|
331
|
+
self.re.http = new RegExp(
|
|
332
|
+
`^\\/\\/${self.re.src_auth}${self.re.src_host_port_strict}${self.re.src_path}`, 'i'
|
|
347
333
|
);
|
|
348
334
|
}
|
|
349
335
|
if (self.re.http.test(tail)) {
|
|
350
|
-
return tail.match(self.re.http)[0].length
|
|
336
|
+
return tail.match(self.re.http)[0].length
|
|
351
337
|
}
|
|
352
|
-
return 0
|
|
338
|
+
return 0
|
|
353
339
|
}
|
|
354
340
|
},
|
|
355
|
-
'https:':
|
|
356
|
-
'ftp:':
|
|
357
|
-
'//':
|
|
341
|
+
'https:': 'http:',
|
|
342
|
+
'ftp:': 'http:',
|
|
343
|
+
'//': {
|
|
358
344
|
validate: function (text, pos, self) {
|
|
359
|
-
|
|
345
|
+
const tail = text.slice(pos);
|
|
360
346
|
|
|
361
347
|
if (!self.re.no_http) {
|
|
362
348
|
// compile lazily, because "host"-containing variables can change on tlds update.
|
|
363
|
-
self.re.no_http =
|
|
349
|
+
self.re.no_http = new RegExp(
|
|
364
350
|
'^' +
|
|
365
351
|
self.re.src_auth +
|
|
366
352
|
// Don't allow single-level domains, because of false positives like '//test'
|
|
367
353
|
// with code comments
|
|
368
|
-
|
|
354
|
+
`(?:localhost|(?:(?:${self.re.src_domain})\\.)+${self.re.src_domain_root})` +
|
|
369
355
|
self.re.src_port +
|
|
370
356
|
self.re.src_host_terminator +
|
|
371
357
|
self.re.src_path,
|
|
@@ -376,73 +362,61 @@ var defaultSchemas = {
|
|
|
376
362
|
|
|
377
363
|
if (self.re.no_http.test(tail)) {
|
|
378
364
|
// should not be `://` & `///`, that protects from errors in protocol name
|
|
379
|
-
if (pos >= 3 && text[pos - 3] === ':') { return 0
|
|
380
|
-
if (pos >= 3 && text[pos - 3] === '/') { return 0
|
|
381
|
-
return tail.match(self.re.no_http)[0].length
|
|
365
|
+
if (pos >= 3 && text[pos - 3] === ':') { return 0 }
|
|
366
|
+
if (pos >= 3 && text[pos - 3] === '/') { return 0 }
|
|
367
|
+
return tail.match(self.re.no_http)[0].length
|
|
382
368
|
}
|
|
383
|
-
return 0
|
|
369
|
+
return 0
|
|
384
370
|
}
|
|
385
371
|
},
|
|
386
372
|
'mailto:': {
|
|
387
373
|
validate: function (text, pos, self) {
|
|
388
|
-
|
|
374
|
+
const tail = text.slice(pos);
|
|
389
375
|
|
|
390
376
|
if (!self.re.mailto) {
|
|
391
|
-
self.re.mailto =
|
|
392
|
-
|
|
377
|
+
self.re.mailto = new RegExp(
|
|
378
|
+
`^${self.re.src_email_name}@${self.re.src_host_strict}`, 'i'
|
|
393
379
|
);
|
|
394
380
|
}
|
|
395
381
|
if (self.re.mailto.test(tail)) {
|
|
396
|
-
return tail.match(self.re.mailto)[0].length
|
|
382
|
+
return tail.match(self.re.mailto)[0].length
|
|
397
383
|
}
|
|
398
|
-
return 0
|
|
384
|
+
return 0
|
|
399
385
|
}
|
|
400
386
|
}
|
|
401
387
|
};
|
|
402
388
|
|
|
403
|
-
/*eslint-disable max-len*/
|
|
404
|
-
|
|
405
389
|
// RE pattern for 2-character tlds (autogenerated by ./support/tlds_2char_gen.js)
|
|
406
|
-
|
|
390
|
+
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]';
|
|
407
391
|
|
|
408
392
|
// DON'T try to make PRs with changes. Extend TLDs with LinkifyIt.tlds() instead
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
/*eslint-enable max-len*/
|
|
393
|
+
const tlds_default = 'biz|com|edu|gov|net|org|pro|web|xxx|aero|asia|coop|info|museum|name|shop|рф'.split('|');
|
|
412
394
|
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
function resetScanCache(self) {
|
|
416
|
-
self.__index__ = -1;
|
|
417
|
-
self.__text_cache__ = '';
|
|
418
|
-
}
|
|
419
|
-
|
|
420
|
-
function createValidator(re) {
|
|
395
|
+
function createValidator (re) {
|
|
421
396
|
return function (text, pos) {
|
|
422
|
-
|
|
397
|
+
const tail = text.slice(pos);
|
|
423
398
|
|
|
424
399
|
if (re.test(tail)) {
|
|
425
|
-
return tail.match(re)[0].length
|
|
400
|
+
return tail.match(re)[0].length
|
|
426
401
|
}
|
|
427
|
-
return 0
|
|
428
|
-
}
|
|
402
|
+
return 0
|
|
403
|
+
}
|
|
429
404
|
}
|
|
430
405
|
|
|
431
|
-
function createNormalizer() {
|
|
406
|
+
function createNormalizer () {
|
|
432
407
|
return function (match, self) {
|
|
433
408
|
self.normalize(match);
|
|
434
|
-
}
|
|
409
|
+
}
|
|
435
410
|
}
|
|
436
411
|
|
|
437
412
|
// Schemas compiler. Build regexps.
|
|
438
413
|
//
|
|
439
|
-
function compile(self) {
|
|
440
|
-
|
|
414
|
+
function compile (self) {
|
|
441
415
|
// Load & clone RE patterns.
|
|
442
|
-
|
|
416
|
+
const re = self.re = reFactory(self.__opts__);
|
|
443
417
|
|
|
444
418
|
// Define dynamic patterns
|
|
445
|
-
|
|
419
|
+
const tlds = self.__tlds__.slice();
|
|
446
420
|
|
|
447
421
|
self.onCompile();
|
|
448
422
|
|
|
@@ -453,32 +427,35 @@ function compile(self) {
|
|
|
453
427
|
|
|
454
428
|
re.src_tlds = tlds.join('|');
|
|
455
429
|
|
|
456
|
-
function untpl(tpl) { return tpl.replace('%TLDS%', re.src_tlds)
|
|
430
|
+
function untpl (tpl) { return tpl.replace('%TLDS%', re.src_tlds) }
|
|
457
431
|
|
|
458
|
-
re.email_fuzzy
|
|
459
|
-
re.
|
|
432
|
+
re.email_fuzzy = RegExp(untpl(re.tpl_email_fuzzy), 'i');
|
|
433
|
+
re.email_fuzzy_global = RegExp(untpl(re.tpl_email_fuzzy), 'ig');
|
|
434
|
+
re.link_fuzzy = RegExp(untpl(re.tpl_link_fuzzy), 'i');
|
|
435
|
+
re.link_fuzzy_global = RegExp(untpl(re.tpl_link_fuzzy), 'ig');
|
|
460
436
|
re.link_no_ip_fuzzy = RegExp(untpl(re.tpl_link_no_ip_fuzzy), 'i');
|
|
461
|
-
re.
|
|
437
|
+
re.link_no_ip_fuzzy_global = RegExp(untpl(re.tpl_link_no_ip_fuzzy), 'ig');
|
|
438
|
+
re.host_fuzzy_test = RegExp(untpl(re.tpl_host_fuzzy_test), 'i');
|
|
462
439
|
|
|
463
440
|
//
|
|
464
441
|
// Compile each schema
|
|
465
442
|
//
|
|
466
443
|
|
|
467
|
-
|
|
444
|
+
const aliases = [];
|
|
468
445
|
|
|
469
446
|
self.__compiled__ = {}; // Reset compiled data
|
|
470
447
|
|
|
471
|
-
function schemaError(name, val) {
|
|
472
|
-
throw new Error(
|
|
448
|
+
function schemaError (name, val) {
|
|
449
|
+
throw new Error(`(LinkifyIt) Invalid schema "${name}": ${val}`)
|
|
473
450
|
}
|
|
474
451
|
|
|
475
452
|
Object.keys(self.__schemas__).forEach(function (name) {
|
|
476
|
-
|
|
453
|
+
const val = self.__schemas__[name];
|
|
477
454
|
|
|
478
455
|
// skip disabled methods
|
|
479
|
-
if (val === null) { return
|
|
456
|
+
if (val === null) { return }
|
|
480
457
|
|
|
481
|
-
|
|
458
|
+
const compiled = { validate: null, link: null };
|
|
482
459
|
|
|
483
460
|
self.__compiled__[name] = compiled;
|
|
484
461
|
|
|
@@ -499,12 +476,12 @@ function compile(self) {
|
|
|
499
476
|
schemaError(name, val);
|
|
500
477
|
}
|
|
501
478
|
|
|
502
|
-
return
|
|
479
|
+
return
|
|
503
480
|
}
|
|
504
481
|
|
|
505
482
|
if (isString(val)) {
|
|
506
483
|
aliases.push(name);
|
|
507
|
-
return
|
|
484
|
+
return
|
|
508
485
|
}
|
|
509
486
|
|
|
510
487
|
schemaError(name, val);
|
|
@@ -518,7 +495,7 @@ function compile(self) {
|
|
|
518
495
|
if (!self.__compiled__[self.__schemas__[alias]]) {
|
|
519
496
|
// Silently fail on missed schemas to avoid errons on disable.
|
|
520
497
|
// schemaError(alias, self.__schemas__[alias]);
|
|
521
|
-
return
|
|
498
|
+
return
|
|
522
499
|
}
|
|
523
500
|
|
|
524
501
|
self.__compiled__[alias].validate =
|
|
@@ -535,27 +512,22 @@ function compile(self) {
|
|
|
535
512
|
//
|
|
536
513
|
// Build schema condition
|
|
537
514
|
//
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
515
|
+
const slist = Object.keys(self.__compiled__)
|
|
516
|
+
.filter(function (name) {
|
|
517
|
+
// Filter disabled & fake schemas
|
|
518
|
+
return name.length > 0 && self.__compiled__[name]
|
|
519
|
+
})
|
|
520
|
+
.map(escapeRE)
|
|
521
|
+
.join('|');
|
|
545
522
|
// (?!_) cause 1.5x slowdown
|
|
546
|
-
self.re.schema_test
|
|
547
|
-
self.re.schema_search = RegExp(
|
|
523
|
+
self.re.schema_test = RegExp(`(^|(?!_)(?:[><\uff5c]|${re.src_ZPCc}))(${slist})`, 'i');
|
|
524
|
+
self.re.schema_search = RegExp(`(^|(?!_)(?:[><\uff5c]|${re.src_ZPCc}))(${slist})`, 'ig');
|
|
525
|
+
self.re.schema_at_start = RegExp(`^${self.re.schema_search.source}`, 'i');
|
|
548
526
|
|
|
549
527
|
self.re.pretest = RegExp(
|
|
550
|
-
|
|
528
|
+
`(${self.re.schema_test.source})|(${self.re.host_fuzzy_test.source})|@`,
|
|
551
529
|
'i'
|
|
552
530
|
);
|
|
553
|
-
|
|
554
|
-
//
|
|
555
|
-
// Cleanup
|
|
556
|
-
//
|
|
557
|
-
|
|
558
|
-
resetScanCache(self);
|
|
559
531
|
}
|
|
560
532
|
|
|
561
533
|
/**
|
|
@@ -563,58 +535,47 @@ function compile(self) {
|
|
|
563
535
|
*
|
|
564
536
|
* Match result. Single element of array, returned by [[LinkifyIt#match]]
|
|
565
537
|
**/
|
|
566
|
-
function Match(
|
|
567
|
-
|
|
568
|
-
end = self.__last_index__,
|
|
569
|
-
text = self.__text_cache__.slice(start, end);
|
|
538
|
+
function Match (text, schema, index, lastIndex) {
|
|
539
|
+
const raw = text.slice(index, lastIndex);
|
|
570
540
|
|
|
571
541
|
/**
|
|
572
542
|
* Match#schema -> String
|
|
573
543
|
*
|
|
574
544
|
* Prefix (protocol) for matched string.
|
|
575
545
|
**/
|
|
576
|
-
this.schema
|
|
546
|
+
this.schema = schema.toLowerCase();
|
|
577
547
|
/**
|
|
578
548
|
* Match#index -> Number
|
|
579
549
|
*
|
|
580
550
|
* First position of matched string.
|
|
581
551
|
**/
|
|
582
|
-
this.index
|
|
552
|
+
this.index = index;
|
|
583
553
|
/**
|
|
584
554
|
* Match#lastIndex -> Number
|
|
585
555
|
*
|
|
586
556
|
* Next position after matched string.
|
|
587
557
|
**/
|
|
588
|
-
this.lastIndex =
|
|
558
|
+
this.lastIndex = lastIndex;
|
|
589
559
|
/**
|
|
590
560
|
* Match#raw -> String
|
|
591
561
|
*
|
|
592
562
|
* Matched string.
|
|
593
563
|
**/
|
|
594
|
-
this.raw
|
|
564
|
+
this.raw = raw;
|
|
595
565
|
/**
|
|
596
566
|
* Match#text -> String
|
|
597
567
|
*
|
|
598
568
|
* Notmalized text of matched string.
|
|
599
569
|
**/
|
|
600
|
-
this.text
|
|
570
|
+
this.text = raw;
|
|
601
571
|
/**
|
|
602
572
|
* Match#url -> String
|
|
603
573
|
*
|
|
604
574
|
* Normalized url of matched string.
|
|
605
575
|
**/
|
|
606
|
-
this.url
|
|
607
|
-
}
|
|
608
|
-
|
|
609
|
-
function createMatch(self, shift) {
|
|
610
|
-
var match = new Match(self, shift);
|
|
611
|
-
|
|
612
|
-
self.__compiled__[match.schema].normalize(match, self);
|
|
613
|
-
|
|
614
|
-
return match;
|
|
576
|
+
this.url = raw;
|
|
615
577
|
}
|
|
616
578
|
|
|
617
|
-
|
|
618
579
|
/**
|
|
619
580
|
* class LinkifyIt
|
|
620
581
|
**/
|
|
@@ -653,9 +614,9 @@ function createMatch(self, shift) {
|
|
|
653
614
|
* - __fuzzyEmail__ - recognize emails without `mailto:` prefix.
|
|
654
615
|
*
|
|
655
616
|
**/
|
|
656
|
-
function LinkifyIt(schemas, options) {
|
|
617
|
+
function LinkifyIt (schemas, options) {
|
|
657
618
|
if (!(this instanceof LinkifyIt)) {
|
|
658
|
-
return new LinkifyIt(schemas, options)
|
|
619
|
+
return new LinkifyIt(schemas, options)
|
|
659
620
|
}
|
|
660
621
|
|
|
661
622
|
if (!options) {
|
|
@@ -665,26 +626,19 @@ function LinkifyIt(schemas, options) {
|
|
|
665
626
|
}
|
|
666
627
|
}
|
|
667
628
|
|
|
668
|
-
this.__opts__
|
|
669
|
-
|
|
670
|
-
// Cache last tested result. Used to skip repeating steps on next `match` call.
|
|
671
|
-
this.__index__ = -1;
|
|
672
|
-
this.__last_index__ = -1; // Next scan position
|
|
673
|
-
this.__schema__ = '';
|
|
674
|
-
this.__text_cache__ = '';
|
|
629
|
+
this.__opts__ = assign({}, defaultOptions, options);
|
|
675
630
|
|
|
676
|
-
this.__schemas__
|
|
677
|
-
this.__compiled__
|
|
631
|
+
this.__schemas__ = assign({}, defaultSchemas, schemas);
|
|
632
|
+
this.__compiled__ = {};
|
|
678
633
|
|
|
679
|
-
this.__tlds__
|
|
680
|
-
this.__tlds_replaced__
|
|
634
|
+
this.__tlds__ = tlds_default;
|
|
635
|
+
this.__tlds_replaced__ = false;
|
|
681
636
|
|
|
682
637
|
this.re = {};
|
|
683
638
|
|
|
684
639
|
compile(this);
|
|
685
640
|
}
|
|
686
641
|
|
|
687
|
-
|
|
688
642
|
/** chainable
|
|
689
643
|
* LinkifyIt#add(schema, definition)
|
|
690
644
|
* - schema (String): rule name (fixed pattern prefix)
|
|
@@ -692,99 +646,63 @@ function LinkifyIt(schemas, options) {
|
|
|
692
646
|
*
|
|
693
647
|
* Add new rule definition. See constructor description for details.
|
|
694
648
|
**/
|
|
695
|
-
LinkifyIt.prototype.add = function add(schema, definition) {
|
|
649
|
+
LinkifyIt.prototype.add = function add (schema, definition) {
|
|
696
650
|
this.__schemas__[schema] = definition;
|
|
697
651
|
compile(this);
|
|
698
|
-
return this
|
|
652
|
+
return this
|
|
699
653
|
};
|
|
700
654
|
|
|
701
|
-
|
|
702
655
|
/** chainable
|
|
703
656
|
* LinkifyIt#set(options)
|
|
704
657
|
* - options (Object): { fuzzyLink|fuzzyEmail|fuzzyIP: true|false }
|
|
705
658
|
*
|
|
706
659
|
* Set recognition options for links without schema.
|
|
707
660
|
**/
|
|
708
|
-
LinkifyIt.prototype.set = function set(options) {
|
|
661
|
+
LinkifyIt.prototype.set = function set (options) {
|
|
709
662
|
this.__opts__ = assign(this.__opts__, options);
|
|
710
|
-
return this
|
|
663
|
+
return this
|
|
711
664
|
};
|
|
712
665
|
|
|
713
|
-
|
|
714
666
|
/**
|
|
715
667
|
* LinkifyIt#test(text) -> Boolean
|
|
716
668
|
*
|
|
717
669
|
* Searches linkifiable pattern and returns `true` on success or `false` on fail.
|
|
718
670
|
**/
|
|
719
|
-
LinkifyIt.prototype.test = function test(text) {
|
|
720
|
-
|
|
721
|
-
this.__text_cache__ = text;
|
|
722
|
-
this.__index__ = -1;
|
|
723
|
-
|
|
724
|
-
if (!text.length) { return false; }
|
|
671
|
+
LinkifyIt.prototype.test = function test (text) {
|
|
672
|
+
if (!text.length) { return false }
|
|
725
673
|
|
|
726
|
-
|
|
674
|
+
let m, re;
|
|
727
675
|
|
|
728
676
|
// try to scan for link with schema - that's the most simple rule
|
|
729
677
|
if (this.re.schema_test.test(text)) {
|
|
730
678
|
re = this.re.schema_search;
|
|
731
679
|
re.lastIndex = 0;
|
|
732
680
|
while ((m = re.exec(text)) !== null) {
|
|
733
|
-
|
|
734
|
-
if (len) {
|
|
735
|
-
this.__schema__ = m[2];
|
|
736
|
-
this.__index__ = m.index + m[1].length;
|
|
737
|
-
this.__last_index__ = m.index + m[0].length + len;
|
|
738
|
-
break;
|
|
739
|
-
}
|
|
681
|
+
if (this.testSchemaAt(text, m[2], re.lastIndex)) { return true }
|
|
740
682
|
}
|
|
741
683
|
}
|
|
742
684
|
|
|
743
685
|
if (this.__opts__.fuzzyLink && this.__compiled__['http:']) {
|
|
744
686
|
// guess schemaless links
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
if (this.__index__ < 0 || tld_pos < this.__index__) {
|
|
749
|
-
if ((ml = text.match(this.__opts__.fuzzyIP ? this.re.link_fuzzy : this.re.link_no_ip_fuzzy)) !== null) {
|
|
750
|
-
|
|
751
|
-
shift = ml.index + ml[1].length;
|
|
752
|
-
|
|
753
|
-
if (this.__index__ < 0 || shift < this.__index__) {
|
|
754
|
-
this.__schema__ = '';
|
|
755
|
-
this.__index__ = shift;
|
|
756
|
-
this.__last_index__ = ml.index + ml[0].length;
|
|
757
|
-
}
|
|
758
|
-
}
|
|
687
|
+
if (text.search(this.re.host_fuzzy_test) >= 0) {
|
|
688
|
+
if (text.match(this.__opts__.fuzzyIP ? this.re.link_fuzzy : this.re.link_no_ip_fuzzy) !== null) {
|
|
689
|
+
return true
|
|
759
690
|
}
|
|
760
691
|
}
|
|
761
692
|
}
|
|
762
693
|
|
|
763
694
|
if (this.__opts__.fuzzyEmail && this.__compiled__['mailto:']) {
|
|
764
695
|
// guess schemaless emails
|
|
765
|
-
|
|
766
|
-
if (at_pos >= 0) {
|
|
696
|
+
if (text.indexOf('@') >= 0) {
|
|
767
697
|
// We can't skip this check, because this cases are possible:
|
|
768
698
|
// 192.168.1.1@gmail.com, my.in@example.com
|
|
769
|
-
if (
|
|
770
|
-
|
|
771
|
-
shift = me.index + me[1].length;
|
|
772
|
-
next = me.index + me[0].length;
|
|
773
|
-
|
|
774
|
-
if (this.__index__ < 0 || shift < this.__index__ ||
|
|
775
|
-
(shift === this.__index__ && next > this.__last_index__)) {
|
|
776
|
-
this.__schema__ = 'mailto:';
|
|
777
|
-
this.__index__ = shift;
|
|
778
|
-
this.__last_index__ = next;
|
|
779
|
-
}
|
|
780
|
-
}
|
|
699
|
+
if (text.match(this.re.email_fuzzy) !== null) { return true }
|
|
781
700
|
}
|
|
782
701
|
}
|
|
783
702
|
|
|
784
|
-
return
|
|
703
|
+
return false
|
|
785
704
|
};
|
|
786
705
|
|
|
787
|
-
|
|
788
706
|
/**
|
|
789
707
|
* LinkifyIt#pretest(text) -> Boolean
|
|
790
708
|
*
|
|
@@ -792,11 +710,10 @@ LinkifyIt.prototype.test = function test(text) {
|
|
|
792
710
|
* can exists. Can be used for speed optimization, when you need to check that
|
|
793
711
|
* link NOT exists.
|
|
794
712
|
**/
|
|
795
|
-
LinkifyIt.prototype.pretest = function pretest(text) {
|
|
796
|
-
return this.re.pretest.test(text)
|
|
713
|
+
LinkifyIt.prototype.pretest = function pretest (text) {
|
|
714
|
+
return this.re.pretest.test(text)
|
|
797
715
|
};
|
|
798
716
|
|
|
799
|
-
|
|
800
717
|
/**
|
|
801
718
|
* LinkifyIt#testSchemaAt(text, name, position) -> Number
|
|
802
719
|
* - text (String): text to scan
|
|
@@ -806,15 +723,14 @@ LinkifyIt.prototype.pretest = function pretest(text) {
|
|
|
806
723
|
* Similar to [[LinkifyIt#test]] but checks only specific protocol tail exactly
|
|
807
724
|
* at given position. Returns length of found pattern (0 on fail).
|
|
808
725
|
**/
|
|
809
|
-
LinkifyIt.prototype.testSchemaAt = function testSchemaAt(text, schema, pos) {
|
|
726
|
+
LinkifyIt.prototype.testSchemaAt = function testSchemaAt (text, schema, pos) {
|
|
810
727
|
// If not supported schema check requested - terminate
|
|
811
728
|
if (!this.__compiled__[schema.toLowerCase()]) {
|
|
812
|
-
return 0
|
|
729
|
+
return 0
|
|
813
730
|
}
|
|
814
|
-
return this.__compiled__[schema.toLowerCase()].validate(text, pos, this)
|
|
731
|
+
return this.__compiled__[schema.toLowerCase()].validate(text, pos, this)
|
|
815
732
|
};
|
|
816
733
|
|
|
817
|
-
|
|
818
734
|
/**
|
|
819
735
|
* LinkifyIt#match(text) -> Array|null
|
|
820
736
|
*
|
|
@@ -831,33 +747,119 @@ LinkifyIt.prototype.testSchemaAt = function testSchemaAt(text, schema, pos) {
|
|
|
831
747
|
* - __text__ - normalized text
|
|
832
748
|
* - __url__ - link, generated from matched text
|
|
833
749
|
**/
|
|
834
|
-
LinkifyIt.prototype.match = function match(text) {
|
|
835
|
-
|
|
750
|
+
LinkifyIt.prototype.match = function match (text) {
|
|
751
|
+
const result = [];
|
|
752
|
+
const type_schemed = [];
|
|
753
|
+
const type_fuzzy_link = [];
|
|
754
|
+
const type_fuzzy_email = [];
|
|
755
|
+
let m, len, re;
|
|
756
|
+
|
|
757
|
+
function choose (a, b) {
|
|
758
|
+
if (!a) { return b }
|
|
759
|
+
if (!b) { return a }
|
|
760
|
+
if (a.index !== b.index) { return a.index < b.index ? a : b }
|
|
761
|
+
return a.lastIndex >= b.lastIndex ? a : b
|
|
762
|
+
}
|
|
836
763
|
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
764
|
+
if (!text.length) { return null }
|
|
765
|
+
|
|
766
|
+
// scan for links with schema
|
|
767
|
+
if (this.re.schema_test.test(text)) {
|
|
768
|
+
re = this.re.schema_search;
|
|
769
|
+
re.lastIndex = 0;
|
|
770
|
+
while ((m = re.exec(text)) !== null) {
|
|
771
|
+
len = this.testSchemaAt(text, m[2], re.lastIndex);
|
|
772
|
+
if (len) {
|
|
773
|
+
type_schemed.push({
|
|
774
|
+
schema: m[2],
|
|
775
|
+
index: m.index + m[1].length,
|
|
776
|
+
lastIndex: m.index + m[0].length + len
|
|
777
|
+
});
|
|
778
|
+
}
|
|
779
|
+
}
|
|
841
780
|
}
|
|
842
781
|
|
|
843
|
-
|
|
844
|
-
|
|
782
|
+
if (this.__opts__.fuzzyLink && this.__compiled__['http:']) {
|
|
783
|
+
re = this.__opts__.fuzzyIP ? this.re.link_fuzzy_global : this.re.link_no_ip_fuzzy_global;
|
|
784
|
+
re.lastIndex = 0;
|
|
785
|
+
while ((m = re.exec(text)) !== null) {
|
|
786
|
+
type_fuzzy_link.push({
|
|
787
|
+
schema: '',
|
|
788
|
+
index: m.index + m[1].length,
|
|
789
|
+
lastIndex: m.index + m[0].length
|
|
790
|
+
});
|
|
791
|
+
}
|
|
792
|
+
}
|
|
845
793
|
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
794
|
+
if (this.__opts__.fuzzyEmail && this.__compiled__['mailto:']) {
|
|
795
|
+
re = this.re.email_fuzzy_global;
|
|
796
|
+
re.lastIndex = 0;
|
|
797
|
+
while ((m = re.exec(text)) !== null) {
|
|
798
|
+
type_fuzzy_email.push({
|
|
799
|
+
schema: 'mailto:',
|
|
800
|
+
index: m.index + m[1].length,
|
|
801
|
+
lastIndex: m.index + m[0].length
|
|
802
|
+
});
|
|
803
|
+
}
|
|
804
|
+
}
|
|
805
|
+
|
|
806
|
+
const indexes = [0, 0, 0];
|
|
807
|
+
let lastIndex = 0;
|
|
808
|
+
|
|
809
|
+
for (;;) {
|
|
810
|
+
const candidates = [
|
|
811
|
+
type_schemed[indexes[0]],
|
|
812
|
+
type_fuzzy_email[indexes[1]],
|
|
813
|
+
type_fuzzy_link[indexes[2]]
|
|
814
|
+
];
|
|
815
|
+
|
|
816
|
+
const candidate = choose(choose(candidates[0], candidates[1]), candidates[2]);
|
|
817
|
+
|
|
818
|
+
if (!candidate) { break }
|
|
819
|
+
|
|
820
|
+
if (candidate === candidates[0]) {
|
|
821
|
+
indexes[0]++;
|
|
822
|
+
} else if (candidate === candidates[1]) {
|
|
823
|
+
indexes[1]++;
|
|
824
|
+
} else {
|
|
825
|
+
indexes[2]++;
|
|
826
|
+
}
|
|
827
|
+
|
|
828
|
+
if (candidate.index < lastIndex) { continue }
|
|
849
829
|
|
|
850
|
-
|
|
851
|
-
|
|
830
|
+
const match = new Match(text, candidate.schema, candidate.index, candidate.lastIndex);
|
|
831
|
+
this.__compiled__[match.schema].normalize(match, this);
|
|
832
|
+
result.push(match);
|
|
833
|
+
lastIndex = candidate.lastIndex;
|
|
852
834
|
}
|
|
853
835
|
|
|
854
836
|
if (result.length) {
|
|
855
|
-
return result
|
|
837
|
+
return result
|
|
856
838
|
}
|
|
857
839
|
|
|
858
|
-
return null
|
|
840
|
+
return null
|
|
859
841
|
};
|
|
860
842
|
|
|
843
|
+
/**
|
|
844
|
+
* LinkifyIt#matchAtStart(text) -> Match|null
|
|
845
|
+
*
|
|
846
|
+
* Returns fully-formed (not fuzzy) link if it starts at the beginning
|
|
847
|
+
* of the string, and null otherwise.
|
|
848
|
+
**/
|
|
849
|
+
LinkifyIt.prototype.matchAtStart = function matchAtStart (text) {
|
|
850
|
+
if (!text.length) return null
|
|
851
|
+
|
|
852
|
+
const m = this.re.schema_at_start.exec(text);
|
|
853
|
+
if (!m) return null
|
|
854
|
+
|
|
855
|
+
const len = this.testSchemaAt(text, m[2], m[0].length);
|
|
856
|
+
if (!len) return null
|
|
857
|
+
|
|
858
|
+
const match = new Match(text, m[2], m.index + m[1].length, m.index + m[0].length + len);
|
|
859
|
+
|
|
860
|
+
this.__compiled__[match.schema].normalize(match, this);
|
|
861
|
+
return match
|
|
862
|
+
};
|
|
861
863
|
|
|
862
864
|
/** chainable
|
|
863
865
|
* LinkifyIt#tlds(list [, keepOld]) -> this
|
|
@@ -874,25 +876,25 @@ LinkifyIt.prototype.match = function match(text) {
|
|
|
874
876
|
*
|
|
875
877
|
* If list is replaced, then exact match for 2-chars root zones will be checked.
|
|
876
878
|
**/
|
|
877
|
-
LinkifyIt.prototype.tlds = function tlds(list, keepOld) {
|
|
878
|
-
list = Array.isArray(list) ? list : [
|
|
879
|
+
LinkifyIt.prototype.tlds = function tlds (list, keepOld) {
|
|
880
|
+
list = Array.isArray(list) ? list : [list];
|
|
879
881
|
|
|
880
882
|
if (!keepOld) {
|
|
881
883
|
this.__tlds__ = list.slice();
|
|
882
884
|
this.__tlds_replaced__ = true;
|
|
883
885
|
compile(this);
|
|
884
|
-
return this
|
|
886
|
+
return this
|
|
885
887
|
}
|
|
886
888
|
|
|
887
889
|
this.__tlds__ = this.__tlds__.concat(list)
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
890
|
+
.sort()
|
|
891
|
+
.filter(function (el, idx, arr) {
|
|
892
|
+
return el !== arr[idx - 1]
|
|
893
|
+
})
|
|
894
|
+
.reverse();
|
|
893
895
|
|
|
894
896
|
compile(this);
|
|
895
|
-
return this
|
|
897
|
+
return this
|
|
896
898
|
};
|
|
897
899
|
|
|
898
900
|
/**
|
|
@@ -900,29 +902,26 @@ LinkifyIt.prototype.tlds = function tlds(list, keepOld) {
|
|
|
900
902
|
*
|
|
901
903
|
* Default normalizer (if schema does not define it's own).
|
|
902
904
|
**/
|
|
903
|
-
LinkifyIt.prototype.normalize = function normalize(match) {
|
|
904
|
-
|
|
905
|
+
LinkifyIt.prototype.normalize = function normalize (match) {
|
|
905
906
|
// Do minimal possible changes by default. Need to collect feedback prior
|
|
906
907
|
// to move forward https://github.com/markdown-it/linkify-it/issues/1
|
|
907
908
|
|
|
908
|
-
if (!match.schema) { match.url =
|
|
909
|
+
if (!match.schema) { match.url = `http://${match.url}`; }
|
|
909
910
|
|
|
910
911
|
if (match.schema === 'mailto:' && !/^mailto:/i.test(match.url)) {
|
|
911
|
-
match.url =
|
|
912
|
+
match.url = `mailto:${match.url}`;
|
|
912
913
|
}
|
|
913
914
|
};
|
|
914
915
|
|
|
915
|
-
|
|
916
916
|
/**
|
|
917
917
|
* LinkifyIt#onCompile()
|
|
918
918
|
*
|
|
919
919
|
* Override to modify basic RegExp-s.
|
|
920
920
|
**/
|
|
921
|
-
LinkifyIt.prototype.onCompile = function onCompile() {
|
|
921
|
+
LinkifyIt.prototype.onCompile = function onCompile () {
|
|
922
922
|
};
|
|
923
923
|
|
|
924
|
-
|
|
925
|
-
var linkifyIt = LinkifyIt;
|
|
924
|
+
var index_cjs = LinkifyIt;
|
|
926
925
|
|
|
927
926
|
var require$$1 = [
|
|
928
927
|
"aaa",
|
|
@@ -2389,7 +2388,7 @@ Object.defineProperty(defaultMatchDecorator, "__esModule", {
|
|
|
2389
2388
|
value: true
|
|
2390
2389
|
});
|
|
2391
2390
|
|
|
2392
|
-
var _linkifyIt =
|
|
2391
|
+
var _linkifyIt = index_cjs;
|
|
2393
2392
|
|
|
2394
2393
|
var _linkifyIt2 = _interopRequireDefault$2(_linkifyIt);
|
|
2395
2394
|
|