Skip to content

Commit df89767

Browse files
authored
Fix manifest.json base file not existing
1 parent 36cf5c2 commit df89767

File tree

1 file changed

+6
-7
lines changed

1 file changed

+6
-7
lines changed

classes/FingerprintFile.php

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -85,10 +85,6 @@ public function hash($query = true): string
8585
{
8686
$root = $this->fileRoot();
8787

88-
if (! F::exists($root)) {
89-
return url($this->file);
90-
}
91-
9288
$filename = null;
9389
if (is_string($query) && F::exists($query)) {
9490
$manifest = json_decode(F::read($query), true);
@@ -109,6 +105,10 @@ public function hash($query = true): string
109105
));
110106
}
111107
} elseif (is_bool($query)) {
108+
if (! F::exists($root)) {
109+
return url($this->file);
110+
}
111+
112112
$filename = implode('.', [
113113
F::name($root),
114114
$query ? F::extension($root) . '?v=' . filemtime($root) : md5_file($root) . '.' . F::extension($root)
@@ -143,7 +143,7 @@ public function integrity(bool $openssl = true): ?string
143143
// https://www.srihash.org/
144144
$data = file_get_contents($root);
145145
$digest_sha384 = openssl_digest($data, "sha384", true);
146-
if($digest_sha384){
146+
if ($digest_sha384) {
147147
$output = base64_encode($digest_sha384);
148148
return 'sha384-' . $output;
149149
}
@@ -153,8 +153,7 @@ public function integrity(bool $openssl = true): ?string
153153
if (is_array($output) && count($output) >= 1) {
154154
return 'sha384-' . $output[0];
155155
}
156-
} catch (\Exception $ex) {
157-
}
156+
} catch (\Exception $ex) {}
158157

159158
return null; // @codeCoverageIgnore
160159
}

0 commit comments

Comments
 (0)