(function ( $ ) {
$.fn.url_sub = function( ) {
return this.each(function () {
let $this = $(this);
let txt = $this.html();
let newtxt = txt.replace(/^([^"]*\s*)(https?:\/\/[^\s"]+)/gi, function(match,p1,p2){
let trunc = p2;
if (trunc.length > 30) {
trunc = trunc.substring(0,30) + "...";
}
return p1+' <a target="_BLANK" href="'+p2+'">'+trunc+'</a> ';
});