diff --git a/js/privatebin.js b/js/privatebin.js index e63ab5fb..930a1315 100644 --- a/js/privatebin.js +++ b/js/privatebin.js @@ -2119,7 +2119,11 @@ jQuery.PrivateBin = (function($, RawDeflate) { if (typeof response === 'string' && response.length > 0) { const shortUrlMatcher = /https?:\/\/[^\s]+/g; const shortUrl = (response.match(shortUrlMatcher) || []).filter(function(a) { - return URL.canParse(a); + try { + return !!new URL(a); + } catch (error) { + return false; + } }).sort(function(a, b) { return a.length - b.length; })[0]; diff --git a/js/test/PasteStatus.js b/js/test/PasteStatus.js index 9a5c60d0..baa6ab33 100644 --- a/js/test/PasteStatus.js +++ b/js/test/PasteStatus.js @@ -56,13 +56,6 @@ describe('PasteStatus', function () { ('#' + encodeURI(fragment)) : ''), clean = jsdom(); - // not available in node before v19.9.0, v18.17.0 - if (typeof URL.canParse !== 'function') { - URL.canParse = function(a) { - return true; - } - } - $('body').html('