Skip to content

Commit

Permalink
Fix code styling issues
Browse files Browse the repository at this point in the history
  • Loading branch information
karlerikounapuu committed Mar 26, 2020
1 parent 1a92844 commit bff1724
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions lib/whois_server.rb
Original file line number Diff line number Diff line change
Expand Up @@ -54,21 +54,25 @@ def receive_data(data)
send_data whois_record.unix_body
else
logger.info "#{ip}: requested: #{data} [searched by: #{name}; No record found]"
send_data(domain_valid_format?(name) ? no_entries_msg : policy_error_msg)
provide_data_body(name)
end
close_connection_after_writing
end

private

def provide_data_body
return send_data(no_entries_msg) if domain_valid_format?(name)

send_data(policy_error_msg)
end

def domain_valid_format?(name)
domain_name_regexp = /\A[a-z0-9\-\u00E4\u00F5\u00F6\u00FC\u0161\u017E]{2,61}\.
([a-z0-9\-\u00E4\u00F5\u00F6\u00FC\u0161\u017E]{2,61}\.)?[a-z0-9]{1,61}\z/x

formatted_domain_name = name.strip.downcase
nil != (formatted_domain_name =~ domain_name_regexp)


end

def policy_error_msg
Expand Down

0 comments on commit bff1724

Please sign in to comment.