Skip to content

Commit

Permalink
remove url validation as it's not necessary
Browse files Browse the repository at this point in the history
  • Loading branch information
stefanbauer committed Oct 6, 2018
1 parent ece2da7 commit 4c4f430
Showing 1 changed file with 0 additions and 20 deletions.
20 changes: 0 additions & 20 deletions src/FaviconExtractor.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,6 @@ public function __construct(FaviconFactoryInterface $faviconFactory, ProviderInt

public function fromUrl(string $url): FaviconExtractorInterface
{
if (!$this->isValidUrl($url)) {
throw new InvalidUrlException();
}

$this->url = $url;

return $this;
Expand Down Expand Up @@ -75,20 +71,4 @@ private function getTargetPath(string $path, string $filename): string
{
return $path.DIRECTORY_SEPARATOR.$filename.'.png';
}

private function isValidUrl(string $url): bool
{
$pattern = '/^
(http|https):\\/\\/
(
[a-z0-9]+([\\-\\.]{1}[a-z_0-9]+)*\\.[a-z]{2,5}
|
(([1-9]?[0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5]).){3}([1-9]?[0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])
)
(:[0-9]+)?
(\\/.*)?
$/ixu';

return preg_match($pattern, $url) > 0;
}
}

0 comments on commit 4c4f430

Please sign in to comment.