summary refs log tree commit diff homepage
path: root/src
diff options
context:
space:
mode:
authorNguyễn Gia Phong <mcsinyx@disroot.org>2023-03-06 17:12:02 +0900
committerNguyễn Gia Phong <mcsinyx@disroot.org>2023-03-06 17:12:02 +0900
commit72e56c93dfda955dd2af05607c7afe2b510fee23 (patch)
treee91565b909f9fbd6ecb8e47c42944dcca7d93d0d /src
parentb7d361f211812e6aab73ef038b06563198611af0 (diff)
downloadhybring-72e56c93dfda955dd2af05607c7afe2b510fee23.tar.gz
Remove redundant checks
Diffstat (limited to 'src')
-rw-r--r--src/http.cr13
1 files 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