Skip to content

Commit

Permalink
Merge pull request liip#1402 from liip/fix-runtime-config-asset-version
Browse files Browse the repository at this point in the history
asset versions: have & instead of second ? when image url already has a query string
  • Loading branch information
dbu authored Oct 28, 2021
2 parents 81d7799 + 0916cd1 commit c34bf27
Showing 1 changed file with 13 additions and 8 deletions.
21 changes: 13 additions & 8 deletions Templating/LazyFilterRuntime.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,8 @@ public function filter(string $path, string $filter, array $config = [], ?string
{
$path = $this->cleanPath($path);
$path = $this->cache->getBrowserPath($path, $filter, $config, $resolver, $referenceType);
if ($this->assetVersion) {
$path .= '?'.$this->assetVersion;
}

return $path;
return $this->appendAssetVersion($path);
}

/**
Expand All @@ -61,11 +58,8 @@ public function filterCache(string $path, string $filter, array $config = [], ?s
$path = $this->cache->getRuntimePath($path, $config);
}
$path = $this->cache->resolve($path, $filter, $resolver);
if ($this->assetVersion) {
$path .= '?'.$this->assetVersion;
}

return $path;
return $this->appendAssetVersion($path);
}

private function cleanPath(string $path): string
Expand All @@ -81,4 +75,15 @@ private function cleanPath(string $path): string

return $path;
}

private function appendAssetVersion(string $path): string
{
if (!$this->assetVersion) {
return $path;
}

$separator = false !== mb_strpos($path, '?') ? '&' : '?';

return $path.$separator.$this->assetVersion;
}
}

0 comments on commit c34bf27

Please sign in to comment.