From ba17e94c5e5763aa42c1fbe49a2bd81e7bd419b2 Mon Sep 17 00:00:00 2001 From: El RIDO Date: Fri, 5 Jan 2024 06:40:12 +0100 Subject: [PATCH] use the newer function, if possible --- js/privatebin.js | 4 ++++ tpl/bootstrap.php | 2 +- tpl/page.php | 2 +- 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/js/privatebin.js b/js/privatebin.js index b10f2d0d..4e370e91 100644 --- a/js/privatebin.js +++ b/js/privatebin.js @@ -2119,6 +2119,10 @@ jQuery.PrivateBin = (function($, RawDeflate) { if (typeof response === 'string' && response.length > 0) { const shortUrlMatcher = /https?:\/\/[^\s]+/g; const shortUrl = (response.match(shortUrlMatcher) || []).filter(function(urlRegExMatch) { + if (typeof URL.canParse === 'function') { + return URL.canParse(urlRegExMatch); + } + // polyfill for older browsers (< 120) & node (< 19.9 & < 18.17) try { return !!new URL(urlRegExMatch); } catch (error) { diff --git a/tpl/bootstrap.php b/tpl/bootstrap.php index 927891ac..d1a54fcb 100644 --- a/tpl/bootstrap.php +++ b/tpl/bootstrap.php @@ -73,7 +73,7 @@ endif; ?> - + diff --git a/tpl/page.php b/tpl/page.php index ba08d2ef..b0b9cc1a 100644 --- a/tpl/page.php +++ b/tpl/page.php @@ -51,7 +51,7 @@ endif; ?> - +