Skip to content

Commit

Permalink
validate url with Nette Validators
Browse files Browse the repository at this point in the history
[Fixes #14]
  • Loading branch information
fprochazka committed May 13, 2017
1 parent 21380dd commit 91748f0
Showing 1 changed file with 1 addition and 3 deletions.
4 changes: 1 addition & 3 deletions src/Kdyby/Console/DI/ConsoleExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -216,9 +216,7 @@ protected function beforeCompileFakeHttp(array $config)
$builder = $this->getContainerBuilder();

if (!empty($config['url'])) {
if (!preg_match('~^https?://[^/]+(/.*)?$~', $config['url'])) {
throw new Nette\Utils\AssertionException("The url '{$config['url']}' is not valid, please use this format: 'http://domain.tld/path'.");
}
Nette\Utils\Validators::assert($config['url'], 'url', 'console.url');
$builder->getDefinition($builder->getByType('Nette\Http\RequestFactory') ?: 'nette.httpRequestFactory')
->setFactory('Kdyby\Console\HttpRequestFactory')
->addSetup('setFakeRequestUrl', [$config['url']]);
Expand Down

0 comments on commit 91748f0

Please sign in to comment.