Skip to content

Commit

Permalink
fixes
Browse files Browse the repository at this point in the history
Signed-off-by: Bruno Meilick <[email protected]>
  • Loading branch information
bnomei committed Jul 31, 2018
1 parent cb5a331 commit 211b532
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "bnomei/kirby3-fingerprint",
"type": "plugin",
"version": "2.0.6",
"version": "2.1.0",
"description": "File Method and css/js helper to add cachbusting hash and optional Subresource Integrity to file",
"license": "MIT",
"autoload": {
Expand Down
6 changes: 3 additions & 3 deletions config.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,15 @@
'cache' => true,
'hash' => function ($file) {
$url = null;
$fileroot = is_a($file, 'File') ? $file->root() : kirby()->roots()->index() . DIRECTORY_SEPARATOR . ltrim(str_replace(kirby()->site()->url(), '', $file), '/');
$fileroot = is_a($file, 'Kirby\Cms\File') ? $file->root() : kirby()->roots()->index() . DIRECTORY_SEPARATOR . ltrim(str_replace(kirby()->site()->url(), '', $file), '/');

if (\Kirby\Toolkit\F::exists($fileroot)) {
$filename = implode('.', [
\Kirby\Toolkit\F::name($fileroot),
\Kirby\Toolkit\F::extension($fileroot) . '?v=' . \filemtime($fileroot)
]);
$dirname = \dirname($fileroot);

$dirname = \dirname($file);
$url = ($dirname === '.') ? $filename : ($dirname . '/' . $filename);
} else {
$url = $file;
Expand All @@ -22,7 +22,7 @@
},
'integrity' => function ($file) {
$sri = null;
$file = is_a($file, 'File') ? $file->root() : kirby()->roots()->index() . DIRECTORY_SEPARATOR . ltrim(str_replace(kirby()->site()->url(), '', $file), '/');
$file = is_a($file, 'Kirby\Cms\File') ? $file->root() : kirby()->roots()->index() . DIRECTORY_SEPARATOR . ltrim(str_replace(kirby()->site()->url(), '', $file), '/');

if (!\Kirby\Toolkit\F::exists($file)) {
return null;
Expand Down

0 comments on commit 211b532

Please sign in to comment.