Skip to content

Commit

Permalink
MenuLink: Add base64_encode() to invalid URL exception + remove white…
Browse files Browse the repository at this point in the history
…spaces.
  • Loading branch information
janbarasek authored Jul 26, 2021
1 parent 954906f commit db9670f
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/Menu/MenuLink.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,12 @@ final class MenuLink

public function __construct(string $label, string $url)
{
$url = trim((string) preg_replace('/\s+/', '', $url));
if (Validators::isUrl($url) === false) {
throw new \InvalidArgumentException('URL is not valid, because "' . $url . '" given.');
throw new \InvalidArgumentException(
'URL is not valid, because "' . $url . '" '
. '(length: ' . strlen($url) . ' bytes, base64: "' . base64_encode($url) . '") given.',
);
}

$this->label = Strings::firstUpper($label);
Expand Down

0 comments on commit db9670f

Please sign in to comment.