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