Merge pull request #96 from leizongmin/master

修正无法正确解析帖子内容中 http://127.0.0.1 这类IP地址的链接
This commit is contained in:
fengmk2 2012-10-17 22:58:54 -07:00
commit 9bebbdf594

View File

@ -195,7 +195,7 @@ this.makeHtml = function (text) {
return wholeMatch;
}
href = wholeMatch.replace(/^http:\/\/github.com\//, "https://github.com/")
var urlreg = /(https?|ftp|mms):\/\/([A-z0-9]+[_\-]?[A-z0-9]+\.)*[A-z0-9]+\-?[A-z0-9]+\.[A-z]{2,}(\/.*)*\/?/;
var urlreg = /(https?|ftp|mms):\/\/((([A-z0-9]+[_\-]?[A-z0-9]+\.)*[A-z0-9]+\-?[A-z0-9]+\.[A-z]{2,})|(([0-9]{1,3}\.){3}[0-9]{1,3}))(\/.*)*\/?/;
return "<a href='" + (urlreg.test(href)?href:("http://www.cnodejs.org"+href)) + "'>" + wholeMatch + "</a>";
});
text = text.replace(/[a-z0-9_\-+=.]+@[a-z0-9\-]+(\.[a-z0-9-]+)+/ig, function(wholeMatch){return "<a href='mailto:" + wholeMatch + "'>" + wholeMatch + "</a>";});