Skip to content

Commit

Permalink
Fixes uri input throwing error when left empty but not required
Browse files Browse the repository at this point in the history
  • Loading branch information
matheuszych authored and klees committed Sep 19, 2024
1 parent be3a374 commit a4c1e32
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions Services/Form/classes/class.ilUriInputGUI.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,16 +45,19 @@ public function checkInput(): bool
{
$lng = $this->lng;

$uri_string = trim($this->getInput());

// check required
if ($this->getRequired() && trim($this->str($this->getPostVar())) == "") {
$this->setAlert($lng->txt("msg_input_is_required"));
return false;
if ($uri_string === "") {
if ($this->getRequired()) {
$this->setAlert($lng->txt("msg_input_is_required"));
return false;
}
return true;
}

$url = $this->getInput();

try {
new URI($url);
new URI($uri_string);
} catch (Throwable $e) {
$this->setAlert($lng->txt("form_invalid_uri"));
return false;
Expand Down

0 comments on commit a4c1e32

Please sign in to comment.