Skip to content

Commit da9ed62

Browse files
authored
Tag Router: Allow numeric/CSV IDs (Regression) (#44784)
1 parent e7c1836 commit da9ed62

File tree

1 file changed

+23
-2
lines changed

1 file changed

+23
-2
lines changed

components/com_tags/src/Service/Router.php

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -278,14 +278,33 @@ public function parse(&$segments)
278278
$vars['view'] = array_shift($segments);
279279
}
280280

281-
$ids = [];
281+
$ids = [];
282+
$matchedAlias = false;
282283

283284
if ($item && $item->query['view'] == 'tag') {
284285
$ids = $item->query['id'];
285286
}
286287

288+
// Iterate through all URL segments and try to parse tag IDs from them
287289
while (\count($segments)) {
288290
$id = array_shift($segments);
291+
292+
// We have a numeric ID
293+
if (!$matchedAlias && is_numeric($id)) {
294+
$ids[] = $id;
295+
296+
// We allow more than one numeric segment in the URL
297+
continue;
298+
}
299+
300+
// We have a comma-separated list of IDs
301+
if (!$matchedAlias && str_contains($id, ',')) {
302+
$ids[] = $id;
303+
304+
// We don't allow more than one list of IDs in a URL
305+
break;
306+
}
307+
289308
$slug = $this->fixSegment($id);
290309

291310
// We did not find the segment as a tag in the DB
@@ -294,7 +313,9 @@ public function parse(&$segments)
294313
break;
295314
}
296315

297-
$ids[] = $slug;
316+
// We don't want to match numeric or comma-separated segments after we matched an alias
317+
$matchedAlias = true;
318+
$ids[] = $slug;
298319
}
299320

300321
if (\count($ids)) {

0 commit comments

Comments
 (0)