Skip to content

Commit

Permalink
feat: add cachebuster on toUrl()
Browse files Browse the repository at this point in the history
  • Loading branch information
BernhardBaumrock committed Jan 14, 2023
1 parent 7e4fec3 commit 63e67a3
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions RockMigrations.module.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ public static function getModuleInfo()
{
return [
'title' => 'RockMigrations',
'version' => '2.11.1',
'version' => '2.12.0',
'summary' => 'The Ultimate Automation and Deployment-Tool for ProcessWire',
'autoload' => 2,
'singular' => true,
Expand Down Expand Up @@ -3464,12 +3464,17 @@ public function toPath($url): string
* If provided a path outside of PW root it will return that path because
* the str_replace only works if the path starts with the pw root path!
*/
public function toUrl($path): string
public function toUrl($path, $cachebuster = false): string
{
$cache = '';
if ($cachebuster) {
$path = $this->toPath($path);
if (is_file($path)) $cache = "?m=" . filemtime($path);
}
return str_replace(
$this->wire->config->paths->root,
$this->wire->config->urls->root,
Paths::normalizeSeparators((string)$path)
Paths::normalizeSeparators((string)$path) . $cache
);
}

Expand Down

0 comments on commit 63e67a3

Please sign in to comment.