Skip to content
Permalink
Browse files

Atuo-detect urls

  • Loading branch information...
Depado committed Dec 3, 2014
1 parent 54c6b84 commit 8086cc94f1cb12a622c4d8ce48de09e2fa69ff2f
Showing with 10 additions and 1 deletion.
  1. +9 −1 app.js
  2. +1 −0 package.json
10 app.js
@@ -6,7 +6,8 @@ var express = require('express'),
validator = require('validator'),
compress = require('compression'),
staticData = require('./static_data'),
generation = require('./generation');
generation = require('./generation'),
validUrl = require('valid-url');

// Nunjucks configuration
nunjucks.configure('views', {
@@ -53,6 +54,13 @@ io.sockets.on('connection', function (socket) {
data = data.replace(re, generation.generate_img_string(key));
}
};
var arr = data.split(" ");
for (var i=0; i<arr.length; i++) {
if (validUrl.isUri(arr[i])){
arr[i] = "<a href='" + arr[i] + "''>" + arr[i] + "</a>";
}
}
data = arr.join(" ");
io.sockets.emit('updatechat', socket.username, data);
break;
}
@@ -9,6 +9,7 @@
"express": "^4.2.0",
"nunjucks": "^1.0.5",
"socket.io": "^0.9.16",
"valid-url": "^1.0.9",
"validator": "^3.12.0"
},
"devDependencies": {},

0 comments on commit 8086cc9

Please sign in to comment.
You can’t perform that action at this time.