diff --git a/README.md b/README.md index fb14d20be..ff11a4370 100644 --- a/README.md +++ b/README.md @@ -73,26 +73,27 @@ Things might work in Edge 15-18, Firefox 47-62 and Chrome 54-68 due to one polyf * Removed matchmedia-polyfill * Removed momentjs (localization still used) * Removed opentip (use CSS) +* Replaced Autolinker with simple https/email detection |js/* |1.14.0 |native |gzip 1.14 |gzip | |----------- |--------: |--------: |--------: |--------: | -|admin.js |2.130.942 |1.119.116 | 485.481 | 270.646 | -|app.js |4.184.455 |2.829.860 | 932.725 | 659.501 | +|admin.js |2.130.942 |1.119.218 | 485.481 | 271.178 | +|app.js |4.184.455 |2.829.958 | 932.725 | 659.546 | |boot.js | 671.522 | 44.029 | 169.502 | 15.460 | -|libs.js | 647.614 | 364.163 | 194.728 | 118.262 | +|libs.js | 647.614 | 318.711 | 194.728 | 99.162 | |polyfills.js | 325.834 | 0 | 71.825 | 0 | -|TOTAL js |7.960.367 |4.357.168 |1.854.261 |1.063.869 | +|TOTAL js |7.960.367 |4.311.916 |1.854.261 |1.045.346 | |js/min/* |1.14.0 |native |gzip 1.14 |gzip | |--------------- |--------: |--------: |--------: |--------: | -|admin.min.js | 252.147 | 151.264 | 73.657 | 43.122 | -|app.min.js | 511.202 | 376.839 |140.462 | 98.898 | +|admin.min.js | 252.147 | 151.652 | 73.657 | 43.325 | +|app.min.js | 511.202 | 377.227 |140.462 | 99.095 | |boot.min.js | 66.007 | 5.589 | 22.567 | 2.333 | -|libs.min.js | 572.545 | 348.651 |176.720 |112.822 | +|libs.min.js | 572.545 | 303.360 |176.720 | 93.728 | |polyfills.min.js | 32.452 | 0 | 11.312 | 0 | -|TOTAL js/min |1.434.353 | 882.343 |424.718 |257.175 | +|TOTAL js/min |1.434.353 | 837.828 |424.718 |238.481 | -552.010 bytes (167.543 gzip) is not much, but it feels faster. +596.525 bytes (186.237 gzip) is not much, but it feels faster. |css/* |1.14.0 |native | diff --git a/dev/Common/Utils.js b/dev/Common/Utils.js index f0f188cd9..06166e24c 100644 --- a/dev/Common/Utils.js +++ b/dev/Common/Utils.js @@ -507,21 +507,13 @@ export function settingsSaveHelperSubscribeFunction(remote, settingName, type, f * @param {string} html * @returns {string} */ +/*eslint-disable max-len*/ +const url = /(^|[\s\n]|\/?>)(https:\/\/[-A-Z0-9+\u0026\u2019#/%?=()~_|!:,.;]*[-A-Z0-9+\u0026#/%=~()_|])/gi, + email = /(^|[\s\n]|\/?>)((?:[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*|"(?:[\x21\x23-\x5b\x5d-\x7f]|\\[\x21\x23-\x5b\x5d-\x7f])*")@(?:(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?|\[(?:(?:(2(5[0-5]|[0-4][0-9])|1[0-9][0-9]|[1-9]?[0-9]))\.){3}(?:(2(5[0-5]|[0-4][0-9])|1[0-9][0-9]|[1-9]?[0-9])|[a-z0-9-]*[a-z0-9]:(?:[\x21-\x5a\x53-\x7f]|\\[\x21\x23-\x5b\x5d-\x7f])+)\]))/gi; export function findEmailAndLinks(html) { - return window.Autolinker - ? window.Autolinker.link(html, { - newWindow: true, - stripPrefix: false, - urls: true, - email: true, - mention: false, - phone: false, - hashtag: false, - replaceFn: function(match) { - return !(match && 'url' === match.getType() && match.matchedText && 0 !== match.matchedText.indexOf('http')); - } - }) - : html; + return html + .replace(url, '$1$2') + .replace(email, '$1$2'); } /** diff --git a/package.json b/package.json index 64ade4f91..16268a051 100644 --- a/package.json +++ b/package.json @@ -52,7 +52,6 @@ "@babel/plugin-transform-runtime": "7.8.3", "@babel/preset-env": "7.8.7", "@babel/runtime-corejs3": "7.8.7", - "autolinker": "3.13.0", "babel-eslint": "10.1.0", "babel-loader": "8.0.6", "copy-webpack-plugin": "5.1.1", diff --git a/tasks/config.js b/tasks/config.js index 350c6c9fe..8961cc6b6 100644 --- a/tasks/config.js +++ b/tasks/config.js @@ -84,7 +84,6 @@ config.paths.js = { 'node_modules/knockout/build/output/knockout-latest.js', 'node_modules/knockout-sortable/build/knockout-sortable.min.js ', 'node_modules/simplestatemanager/dist/ssm.min.js', - 'node_modules/autolinker/dist/Autolinker.min.js', 'vendors/lightgallery/dist/js/lightgallery.min.js', // license 'vendors/lightgallery/dist/js/lg-fullscreen.min.js', 'vendors/lightgallery/dist/js/lg-thumbnail.min.js', diff --git a/yarn.lock b/yarn.lock index 49599bc3f..bc5d1290c 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1396,13 +1396,6 @@ atob@^2.1.1: version "2.1.2" resolved "https://registry.yarnpkg.com/atob/-/atob-2.1.2.tgz#6d9517eb9e030d2436666651e86bd9f6f13533c9" -autolinker@3.13.0: - version "3.13.0" - resolved "https://registry.yarnpkg.com/autolinker/-/autolinker-3.13.0.tgz#7a51244bb11bf75de89a48047919e93071e78f43" - integrity sha512-qlM0Su9lYYJ7lAth6xxB0rRdpS4FGmRboaghmM45Ud6ygGZa/TK/cbRAX6afvusJ79vyciy18QSKrWTM6cJHiw== - dependencies: - tslib "^1.9.3" - autoprefixer@^9.6.1: version "9.6.5" resolved "https://registry.yarnpkg.com/autoprefixer/-/autoprefixer-9.6.5.tgz#98f4afe7e93cccf323287515d426019619775e5e"