From f03f2bf28d3ab2917487fee7b02f1e6c23a977d2 Mon Sep 17 00:00:00 2001 From: El RIDO Date: Thu, 25 Sep 2025 22:06:38 +0200 Subject: [PATCH] simplify cache breaker extraction --- js/privatebin.js | 14 +++----------- lib/Configuration.php | 2 +- 2 files changed, 4 insertions(+), 12 deletions(-) diff --git a/js/privatebin.js b/js/privatebin.js index acb3f4a0..4e765db3 100644 --- a/js/privatebin.js +++ b/js/privatebin.js @@ -930,16 +930,8 @@ jQuery.PrivateBin = (function($) { } // load strings from JSON - let main_script = document.querySelector('script[src^="js/privatebin.js"]'); - let privatebin_version; - - if (main_script) { - privatebin_version = main_script.getAttribute("src").split("?")[1] || null; - } else { - privatebin_version = Math.floor(Date.now() / 60000); - } - - $.getJSON('i18n/' + newLanguage + '.json?v=' + privatebin_version, function(data) { + const cacheBreaker = document.querySelector('script[src^="js/privatebin.js"]').getAttribute("src").split(".js")[1] || ""; + $.getJSON('i18n/' + newLanguage + '.json' + cacheBreaker, function(data) { language = newLanguage; translations = data; $(document).triggerHandler(languageLoadedEvent); @@ -2141,7 +2133,7 @@ jQuery.PrivateBin = (function($) { // if so, we send the link to the shortener // we do not remove the button, in case shortener fails sendToShortener(); - } + } } /** diff --git a/lib/Configuration.php b/lib/Configuration.php index e0e5982a..a4cc7013 100644 --- a/lib/Configuration.php +++ b/lib/Configuration.php @@ -121,7 +121,7 @@ class Configuration 'js/kjua-0.10.0.js' => 'sha512-BYj4xggowR7QD150VLSTRlzH62YPfhpIM+b/1EUEr7RQpdWAGKulxWnOvjFx1FUlba4m6ihpNYuQab51H6XlYg==', 'js/legacy.js' => 'sha512-08+subq1Lo+r+la5ENqeXiMgNJcVaaTtBIFGkrjziSpvtgCId3Jtin4/OkSdHYSoeztwwIab8uvCzPKHta6puQ==', 'js/prettify.js' => 'sha512-puO0Ogy++IoA2Pb9IjSxV1n4+kQkKXYAEUtVzfZpQepyDPyXk8hokiYDS7ybMogYlyyEIwMLpZqVhCkARQWLMg==', - 'js/privatebin.js' => 'sha512-mqzsqmoDJRcSQCjIU3TiE4vNqgpmjrwxhscCATiHwlAaMaat2J1epLUK7995vX7UW6CfkpOWhz2dvwLQO/NQFg==', + 'js/privatebin.js' => 'sha512-Id47n8ZPz6j93KoR7DkaS48MxtwKftVq3RyZw9WRGpRT+6bYKP/ZkU84RscbcW3icxBTS9fQKQpdnmZ3rr00dQ==', 'js/purify-3.2.6.js' => 'sha512-zqwL4OoBLFx89QPewkz4Lz5CSA2ktU+f31fuECkF0iK3Id5qd3Zpq5dMby8KwHjIEpsUgOqwF58cnmcaNem0EA==', 'js/showdown-2.1.0.js' => 'sha512-WYXZgkTR0u/Y9SVIA4nTTOih0kXMEd8RRV6MLFdL6YU8ymhR528NLlYQt1nlJQbYz4EW+ZsS0fx1awhiQJme1Q==', 'js/zlib-1.3.1-1.js' => 'sha512-5bU9IIP4PgBrOKLZvGWJD4kgfQrkTz8Z3Iqeu058mbQzW3mCumOU6M3UVbVZU9rrVoVwaW4cZK8U8h5xjF88eQ==',