From 4b6c8356f5544774488385df582c77a8df599dd0 Mon Sep 17 00:00:00 2001 From: El RIDO Date: Tue, 9 Jul 2024 22:35:21 +0200 Subject: [PATCH] clarify use of cache buster, avoid using regex --- lib/View.php | 7 ++++--- tst/Bootstrap.php | 2 -- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/lib/View.php b/lib/View.php index 0caa911d..958be833 100644 --- a/lib/View.php +++ b/lib/View.php @@ -69,10 +69,11 @@ class View { $sri = array_key_exists($file, $this->_variables['SRI']) ? ' integrity="' . $this->_variables['SRI'][$file] . '"' : ''; - $suffix = preg_match('#\d.js$#', $file) == 0 ? - '?' . rawurlencode($this->_variables['VERSION']) : ''; + // if the file isn't versioned (ends in a digit), add our own version + $cacheBuster = ctype_digit(substr($file, -4, 1)) ? + '' : '?' . rawurlencode($this->_variables['VERSION']); echo '', PHP_EOL; + $cacheBuster, '"', $sri, ' crossorigin="anonymous">', PHP_EOL; } } diff --git a/tst/Bootstrap.php b/tst/Bootstrap.php index c43e2b25..28b56422 100644 --- a/tst/Bootstrap.php +++ b/tst/Bootstrap.php @@ -1,7 +1,5 @@