Skip to content
This repository has been archived by the owner on Dec 12, 2021. It is now read-only.

Commit

Permalink
Added option to enable/disable fingerprinting
Browse files Browse the repository at this point in the history
  • Loading branch information
S1SYPHOS committed Nov 17, 2017
1 parent 35d64b3 commit 573b026
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 10 deletions.
12 changes: 7 additions & 5 deletions core/css.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,13 @@ public function tag($url, $media = null) {
$cssInput = (new Asset($url))->content();
$cssIntegrity = sri_checksum($cssInput);

// add timestamp for cache-busting
$modified = filemtime($url);
$filename = f::name($url) . '.' . $modified . '.' . f::extension($url);
$dirname = f::dirname($url);
$url = ($dirname === '.') ? $filename : $dirname . '/' . $filename;
if(settings::fingerprinting()) {
// add timestamp for cache-busting
$modified = filemtime($url);
$filename = f::name($url) . '.' . $modified . '.' . f::extension($url);
$dirname = f::dirname($url);
$url = ($dirname === '.') ? $filename : $dirname . '/' . $filename;
}

// build an array of SRI-related attributes
$cssOptions = array(
Expand Down
12 changes: 7 additions & 5 deletions core/js.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,13 @@ public function tag($src, $async = false) {
$jsInput = (new Asset($src))->content();
$jsIntegrity = sri_checksum($jsInput);

// add timestamp for cache-busting
$modified = filemtime($src);
$filename = f::name($src) . '.' . $modified . '.' . f::extension($src);
$dirname = f::dirname($src);
$src = ($dirname === '.') ? $filename : $dirname . '/' . $filename;
if(settings::fingerprinting()) {
// add timestamp for cache-busting
$modified = filemtime($src);
$filename = f::name($src) . '.' . $modified . '.' . f::extension($src);
$dirname = f::dirname($src);
$src = ($dirname === '.') ? $filename : $dirname . '/' . $filename;
}

// build an array of SRI-related attributes
$jsOptions = array(
Expand Down
1 change: 1 addition & 0 deletions kirby-sri.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ public static function __callStatic($name, $args) {
$settings = [
'algorithm' => 'sha512', // Cryptographic hash algorithm
'crossorigin' => 'anonymous', // CORS settings attribute
'fingerprinting' => true, // Enables / disables fingerprinting
];
// If config settings exist, return the config with fallback
if(isset($settings) && array_key_exists($name, $settings)) {
Expand Down

0 comments on commit 573b026

Please sign in to comment.