From 8e44f52f7cbdef6cbee9f1a97ffaea38b37c1e6f Mon Sep 17 00:00:00 2001 From: Tao Zhou Date: Tue, 25 Feb 2020 11:44:12 +0100 Subject: [PATCH] Fix ba-linkify on emails with url-like names foo.com@test.com should be recognized as an email. currently because url patterns are matched before email pattern, so it will be recognized as two urls instead of one email. As upstream for ba-linkify has not been updated for 10 years: https://github.com/cowboy/javascript-linkify Will propose to fix it in local copy directly. Change-Id: I1f33cd600885b759d2e2707fe97a72f4bc656248 --- lib/ba-linkify/src/ba-linkify.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/lib/ba-linkify/src/ba-linkify.js b/lib/ba-linkify/src/ba-linkify.js index 32fbea3e12..461aff97fb 100644 --- a/lib/ba-linkify/src/ba-linkify.js +++ b/lib/ba-linkify/src/ba-linkify.js @@ -23,6 +23,12 @@ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR * OTHER DEALINGS IN THE SOFTWARE. */ + /** + * Note(taoalpha): + * + * To support emails with dots in the name: `foo.bar@test.com`, + * the match regex was modified to match `email` first before urls. + */ /*! * JavaScript Linkify - v0.3 - 6/27/2009 * http://benalman.com/projects/javascript-linkify/ @@ -108,7 +114,7 @@ window.linkify = (function(){ MAILTO = "mailto:", EMAIL = "(?:" + MAILTO + ")?[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@" + HOST_OR_IP + QUERY_FRAG + "(?!\\w)", - URI_RE = new RegExp( "(?:" + URI1 + "|" + URI2 + "|" + EMAIL + ")", "ig" ), + URI_RE = new RegExp( "(?:" + EMAIL + "|" + URI1 + "|" + URI2 + ")", "ig" ), SCHEME_RE = new RegExp( "^" + SCHEME, "i" ), quotes = {