'use strict';

var httpclient = require('../../http-client');

function messageListener(db, from, channel, message) {

  var match = /(https?:\/\/[^ ]+)/.match(message)

  if (match) {

    var res = httpclient(db, match[1]);
    var match = /<title>(.+)<\/title>/.exec(res);

    if (match) {
      var decoded = match[1].replace(/&#\d+;/gm,function(s) {
        return String.fromCharCode(s.match(/\d+/gm)[0]);
      });
      decoded = decoded.replace(/&amp;/g, "&")
                       .replace(/&lt;/g, "<")
                       .replace(/&gt;/g, ">")
                       .replace(/&quot;/g, "\"")
                       .replace(/&#39;/g, "'");
      return [ { to: channel, message: decoded } ] ;
    }

  }

}

module.exports = messageListener;

@@ -147,21 +147,20 @@
 %5B%5E %5D+)/.
-match
+exec
 (message

Use the correct match function