From 23d890274d9db1dfeb6660663c7b61d9f27cd8c5 Mon Sep 17 00:00:00 2001 From: Daniel Lanciana Date: Tue, 22 Mar 2016 17:19:28 -0400 Subject: [PATCH] feat(email href): convert emails to mailto links Add caret symbol to Twitter and Github username tags (e.g. @foo) so as not to conflict with email address (e.g. foo@bar.com). --- angular-linkify.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/angular-linkify.js b/angular-linkify.js index a00f413..52f44a0 100644 --- a/angular-linkify.js +++ b/angular-linkify.js @@ -24,16 +24,19 @@ angular.module('linkify') return ''; } + // Email + _text = _text.replace(/((([a-zA-Z]|[0-9])|([-]|[_]|[.]))+[@](([a-zA-Z0-9])|([-])){2,63}[.](([a-zA-Z0-9]){2,63})+)/g, '$1'); + // Twitter if (type === 'twitter') { - _text = _text.replace(/(|\s)*@([\u00C0-\u1FFF\w]+)/g, '$1@$2'); + _text = _text.replace(/(^|\s)*@([\u00C0-\u1FFF\w]+)/g, '$1@$2'); _text = _text.replace(/(^|\s)*#([\u00C0-\u1FFF\w]+)/g, '$1#$2'); } // Github if (type === 'github') { - _text = _text.replace(/(|\s)*@(\w+)/g, '$1@$2'); + _text = _text.replace(/(^|\s)*@(\w+)/g, '$1@$2'); } return _text;