relax URL regex to support finding IDN domains, filter using built in function, removing non-URLs

This commit is contained in:
El RIDO 2024-01-04 06:48:34 +01:00
parent 9a707e288a
commit 7cb1f8ca67
3 changed files with 4 additions and 4 deletions

View file

@ -2041,8 +2041,8 @@ jQuery.PrivateBin = (function($, RawDeflate) {
responseString = JSON.stringify(responseString);
}
if (typeof responseString === 'string' && responseString.length > 0) {
const shortUrlMatcher = /https?:\/\/(www\.)?[-a-zA-Z0-9@:%._\+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b([-a-zA-Z0-9()@:%_\+.~#?&//=]*)/g;
const shortUrl = (responseString.match(shortUrlMatcher) || []).sort(function(a, b) {
const shortUrlMatcher = /https?:\/\/[^\s]+/g;
const shortUrl = (responseString.match(shortUrlMatcher) || []).filter(URL.canParse).sort(function(a, b) {
return a.length - b.length;
})[0];
if (typeof shortUrl === 'string' && shortUrl.length > 0) {