X-Git-Url: https://git.cweiske.de/shpub.git/blobdiff_plain/3c23b2cde4f8d6de57d5e1cc86828d6d200da65d..fa014d88919516a9763a6a9ab0c620ef102f04e4:/src/shpub/Validator.php diff --git a/src/shpub/Validator.php b/src/shpub/Validator.php index f7f3605..c751595 100644 --- a/src/shpub/Validator.php +++ b/src/shpub/Validator.php @@ -16,11 +16,30 @@ class Validator } if (!isset($parts['host'])) { - Log::err('Invalid URL: No host in ' . $helpName); - return false; + if (count($parts) == 1 && isset($parts['path'])) { + //parse_url('example.org') puts 'example.org' in the path + // but this is common, so we fix it. + $url = 'http://' . $parts['path']; + } else { + Log::err('Invalid URL: No host in ' . $helpName); + return false; + } } return $url; } + + public static function rsvp($answer) + { + $allowed = ['yes', 'no', 'maybe']; + if (false === array_search($answer, $allowed)) { + Log::err( + 'Invalid RSVP answer given; allowed are: ' + . implode(', ', $allowed) + ); + return false; + } + return $answer; + } } ?>