Fix rubocop violations

This commit is contained in:
Rafael Mendonça França 2023-01-17 19:51:40 +00:00
parent 732bd05a64
commit 9ecc8785ef
No known key found for this signature in database
GPG Key ID: FC23B6D0F1EEE948
3 changed files with 7 additions and 7 deletions

@ -200,7 +200,7 @@ def _url_host_allowed?(url)
return true if host == request.host
return false unless host.nil?
return false unless url.to_s.start_with?("/")
return !url.to_s.start_with?("//")
!url.to_s.start_with?("//")
rescue ArgumentError, URI::Error
false
end

@ -450,7 +450,7 @@ def handle_options(options)
if options[:domain] == :all || options[:domain] == "all"
cookie_domain = ""
dot_splitted_host = request.host.split('.', -1)
dot_splitted_host = request.host.split(".", -1)
# Case where request.host is not an IP address or it's an invalid domain
# (ip confirms to the domain structure we expect so we explicitly check for ip)
@ -460,19 +460,19 @@ def handle_options(options)
end
# If there is a provided tld length then we use it otherwise default domain.
if options[:tld_length].present?
if options[:tld_length].present?
# Case where the tld_length provided is valid
if dot_splitted_host.length >= options[:tld_length]
cookie_domain = dot_splitted_host.last(options[:tld_length]).join('.')
cookie_domain = dot_splitted_host.last(options[:tld_length]).join(".")
end
# Case where tld_length is not provided
else
# Regular TLDs
if !(/([^.]{2,3}\.[^.]{2})$/.match?(request.host))
cookie_domain = dot_splitted_host.last(2).join('.')
cookie_domain = dot_splitted_host.last(2).join(".")
# **.**, ***.** style TLDs like co.uk and com.au
else
cookie_domain = dot_splitted_host.last(3).join('.')
cookie_domain = dot_splitted_host.last(3).join(".")
end
end

@ -259,7 +259,7 @@ def set_cookie_with_domain_and_tld
def set_cookie_with_domain_and_longer_tld
cookies[:user_name] = { value: "rizwanreza", domain: :all, tld_length: 4 }
head :ok
head :ok
end
def delete_cookie_with_domain_and_tld