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