Skip to content

Commit

Permalink
Merge pull request #28 from DerFloe/fix/vite-build-hash
Browse files Browse the repository at this point in the history
fix: replace strpos with strrpos since file names could be kebap case
  • Loading branch information
khalwat authored Aug 13, 2024
2 parents 8ff1d34 + 0e0e11c commit c61a32c
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/helpers/ManifestHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -320,14 +320,15 @@ protected static function filenameWithoutHash(string $path): string
$pathInfo = pathinfo($path);
$filename = $pathInfo['filename'];
$extension = $pathInfo['extension'];
$hashPos = strpos($filename, '.') ?: strlen($filename);
$hashPos = strrpos($filename, '.') ?: strlen($filename);
$hash = substr($filename, $hashPos);
// Vite 5 now uses a `-` to separate the version hash, so account for that as well
if (empty($hash) && str_contains($filename, '-')) {
$hash = substr($filename, strpos($filename, '-'));
$hash = substr($filename, strrpos($filename, '-'));
}
$filename = str_replace($hash, '', $filename);

return implode('.', [$filename, $extension]);
}
}

0 comments on commit c61a32c

Please sign in to comment.