Skip to content
Snippets Groups Projects
Commit b9e0f068 authored by deuce's avatar deuce
Browse files

Work some URI wrapping magic.

parent f04fcdbb
No related branches found
No related tags found
No related merge requests found
...@@ -183,12 +183,19 @@ function idx_to_user(fromidx) ...@@ -183,12 +183,19 @@ function idx_to_user(fromidx)
} }
function make_links(str) { function make_links(str) {
str=str.replace(/(?:http|https|ftp|telnet|gopher|irc|news):\/\/[\w\-\.]+\.[a-zA-Z]+(?::[\w-+_%]*)?(?:\/(?:[\w\-._\?\,\/\\\+&;%\$#\=~\*]*))?/gi,function(str) { str=str.replace(/(?:http|https|ftp|telnet|gopher|irc|news):\/\/[\w\-\.]+\.[a-zA-Z]+(?::[\w-+_%]*)?(?:\/(?:[\r\n\w\-._\?\,\/\\\+&;%\$#\=~\*]*))?/gi,function(str) {
// | Protocol |Hostname |TLD | Port | Path | // | Protocol |Hostname |TLD | Port | Path allow line breaks in path (will be stripped)
var ret='<a href="'+str+'" target="_blank">'+str+'</a>'; var text=str;
var uri=str;
var extra='';
var m=str.match(/^(.*)(&gt;|[,.\)])$/); var m=str.match(/^(.*)(&gt;|[,.\)])$/);
if(m!=null) if(m!=null) {
ret='<a href="'+m[1]+'" target="_blank">'+m[1]+'</a>'+m[2]; text=m[1];
uri=m[1];
extra=m[2];
}
uri=uri.replace(/[\r\n]/g,'');
var ret='<a href="'+uri+'" target="_blank">'+text+'</a>'+extra;
return(ret);} return(ret);}
); );
return(str); return(str);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment