Skip to content

Commit a7f1b28

Browse files
committed
fix tag urls not filtering properly
1 parent cac93c7 commit a7f1b28

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

templates/element/Packages/package-tile.php

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,13 @@
99
$tagGroups = $package->cake_php_tag_groups;
1010
krsort($tagGroups);
1111
$existingSlugs = (array)($query['cakephp_slugs'] ?? []);
12+
$currentPath = $this->getRequest()->getPath() ?: '/';
13+
$buildFilterUrl = static function (string $path, array $params): string {
14+
$queryString = http_build_query($params, '', '&', PHP_QUERY_RFC3986);
15+
$queryString = preg_replace('/%5B\d+%5D=/', '%5B%5D=', $queryString) ?? $queryString;
16+
17+
return $queryString === '' ? $path : $path . '?' . $queryString;
18+
};
1219
$packageId = preg_replace('/[^a-z0-9]/i', '-', strtolower($package->package));
1320
$dialogId = 'compat-' . $packageId;
1421
?>
@@ -108,7 +115,7 @@ class="btn btn-xs <?= $isActive ? 'btn-primary' : 'btn-soft btn-primary' ?>">
108115
: array_values(array_unique(array_merge($existingSlugs, [$slug])));
109116
unset($tagQuery['page']);
110117
?>
111-
<a href="<?= h($this->Url->build(['?' => $tagQuery])) ?>"
118+
<a href="<?= h($buildFilterUrl($currentPath, $tagQuery)) ?>"
112119
class="btn btn-xs <?= $tagIsActive ? 'btn-error' : 'btn-soft btn-error' ?>">
113120
<?= h(str_replace('CakePHP: ', '', $tag->label)) ?>
114121
</a>

0 commit comments

Comments
 (0)