Remove unevenly supported lookbehind from link preview regular expression

- Simplify link preview condition
This commit is contained in:
Hypolite Petovan 2019-08-29 21:12:46 -04:00
parent ce7ec11d1d
commit 3670e7f9c8

View file

@ -52,7 +52,7 @@
<div class="clear"></div>\
<hr class="previewseparator">';
var text;
var urlRegex = /(?<!=)(https?\:\/\/|\s)[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,4})(\/+[a-z0-9_.\:\;-]*)*(\?[\&\%\|\+a-z0-9_=,\.\:\;-]*)?([\&\%\|\+&a-z0-9_=,\:\;\.-]*)([\!\#\/\&\%\|\+a-z0-9_=,\:\;\.-]*)}*/i;
var urlRegex = /^(?:https?\:\/\/|\s)[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,4})(?:\/+[a-z0-9_.\:\;-]*)*(?:\?[\&\%\|\+a-z0-9_=,\.\:\;-]*)?(?:[\&\%\|\+&a-z0-9_=,\:\;\.-]*)(?:[\!\#\/\&\%\|\+a-z0-9_=,\:\;\.-]*)}*$/i;
var binurl;
var block = false;
var blockTitle = false;
@ -133,8 +133,7 @@
return;
}
if (trim(text) !== "") {
if (block === false && urlRegex.test(text)) {
if (trim(text) !== "" && block === false && urlRegex.test(text)) {
binurl = bin2hex(text);
block = true;
@ -148,7 +147,6 @@
getContentData(binurl, processContentData);
}
}
}
};
/**