Skip to content

Commit 1771c59

Browse files
authored
Fix proper match check when generating URLs
Observation: `preg_match` doesn't work properly with delimited slashes.
1 parent 3579bcc commit 1771c59

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

src/Routing/HierarchicalUrlGenerator.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,8 +71,10 @@ public function generate($name, $parameters = [], $referenceType = UrlGeneratorI
7171
$groups = $requirement->anyRecordRouteConstraintSplitted();
7272
$index = 0;
7373
foreach ($groups as $group) {
74-
$matches = preg_match("($group)", $parameters['slug']);
75-
if ($matches === 1) {
74+
// $matches = preg_match("($group)", $parameters['slug']);
75+
$lines = explode('|', $group);
76+
$matches = in_array($parameters['slug'], $lines);
77+
if ($matches) {
7678
return $this->wrapped->generate($name . '_' . $index, $parameters, $referenceType);
7779
}
7880
$index++;

0 commit comments

Comments
 (0)