From 72e56c93dfda955dd2af05607c7afe2b510fee23 Mon Sep 17 00:00:00 2001 From: Nguyễn Gia Phong Date: Mon, 6 Mar 2023 17:12:02 +0900 Subject: Remove redundant checks --- src/http.cr | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/src/http.cr b/src/http.cr index ac688fb..912a46c 100644 --- a/src/http.cr +++ b/src/http.cr @@ -71,18 +71,17 @@ class Server if uri.scheme != "http" && uri.scheme != "https" next errors["opennic"] = "Must be HTTP/S" end - host = uri.host - unless OPENNIC_TLD.includes? Path[host].extension + unless OPENNIC_TLD.includes? Path[uri.host.not_nil!].extension next errors["opennic"] = "Must be under OpenNIC domain" - end if host + end when "icann" uri = URI.parse value next errors["icann"] = "Must be absolute URL" unless uri.absolute? next errors["icann"] = "Must be HTTPS" unless uri.scheme == "https" - host = uri.host # impractical to check for ICANN TLD - if OPENNIC_TLD.includes? Path[host].extension + # impractical to check for ICANN TLD + if OPENNIC_TLD.includes? Path[uri.host.not_nil!].extension next errors["icann"] = "Must not be under OpenNIC domain" - end if host + end when "host" else break invalid_param = true @@ -110,7 +109,7 @@ class Server @db.add_applicant params["nick"], params["opennic"], params["icann"] # TODO: write feed else - context.response.status_code = 400 unless errors.empty? + context.response.status_code = 400 end context.response.content_type = "application/xhtml+xml" if params["host"] == @opennic_host -- cgit 1.4.1