Skip to content

Commit

Permalink
upd url manager
Browse files Browse the repository at this point in the history
  • Loading branch information
phphleb committed Jun 23, 2024
1 parent db4cbb3 commit a843bef
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions Constructor/Data/UrlManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public function getUrlAddressByName(array $routes, string $name, array $replacem
return '/';
}
if (\str_contains($address, '?') && ($endPart === false ||
($endPart === null && \count($replacements) === \substr_count($address, '{') - 1))
($endPart === null && \count($replacements) === \substr_count($address, '{') - 1))
) {
$parts = \explode('/', $address);
if (\count($parts) === 1) {
Expand All @@ -64,13 +64,15 @@ public function getUrlAddressByName(array $routes, string $name, array $replacem
DynamicParams::isEndingUrl() and $address .= '/';

if (\str_contains($address, '{')) {
throw new InvalidArgumentException('Wrong number of replacement parts for URL.');
\preg_match_all('/\{(.*?)\}/', $address, $matches);

throw new InvalidArgumentException('Wrong number of replacement parts for URL: ' . \implode(',', $matches[1] ?? []) . " Route name `{$name}`");
}

return '/' . $address;
}

throw new InvalidArgumentException('No match for route by name.');
throw new InvalidArgumentException("No match for route by name `{$name}`");
}

/**
Expand Down

0 comments on commit a843bef

Please sign in to comment.