From 0be400da19af2a7b1cda0001f2b4b9ec8f2064f6 Mon Sep 17 00:00:00 2001 From: loks0n <22452787+loks0n@users.noreply.github.com> Date: Thu, 30 Jan 2025 17:13:09 +0000 Subject: [PATCH] fix: validator description --- src/Appwrite/Network/Validator/Redirect.php | 27 +++++++++++++-------- 1 file changed, 17 insertions(+), 10 deletions(-) diff --git a/src/Appwrite/Network/Validator/Redirect.php b/src/Appwrite/Network/Validator/Redirect.php index 8619f1eb60..cf6d9f7f73 100644 --- a/src/Appwrite/Network/Validator/Redirect.php +++ b/src/Appwrite/Network/Validator/Redirect.php @@ -32,17 +32,24 @@ class Redirect extends Host * * @return string */ - public function getDescription(): string - { - $hostnames = array_map(function ($hostname) { - return "http://`$hostname`"; - }, $this->hostnames); + public function getDescription(): string + { + $schemes = ''; + if (!empty($this->schemes)) { + $schemes = "URL scheme must be one of the following: " . implode(", ", array_map(function ($scheme) { + return "`$scheme`://"; + }, $this->schemes)); + } - return "URL scheme must be one of the following: " . - \implode(", ", $this->schemes) . - " or URL hostname must be one of the following: " . - \implode(", ", $hostnames); - } + $hostnames = ''; + if (!empty($this->hostnames)) { + $hostnames = "URL hostname must be one of the following: " . implode(", ", array_map(function ($hostname) { + return "http://`$hostname`"; + }, $this->hostnames)); + } + + return $schemes . ($schemes && $hostnames ? " or " : "") . $hostnames; + } /** * Is valid