Skip to content

Instantly share code, notes, and snippets.

@rajib
rajib / gist:9407297
Created March 7, 2014 07:59
Linkify Message
Utility = function () {
return {
linkify: function (text) {
if (text) {
text = text.replace(
/((https?\:\/\/)|(www\.))(\S+)(\w{2,4})(:[0-9]+)?(\/|\/([\w#!:.?+=&%@!\-\/]))?/gi,
function(url){
var full_url = url;
if (!full_url.match('^https?:\/\/')) {
full_url = 'http://' + full_url;