Skip to content

Commit

Permalink
Merge pull request #173 from github/nil-check
Browse files Browse the repository at this point in the history
Add a missing nil check around cname_to_domain_to_pages?
  • Loading branch information
yoannchaudet authored Sep 17, 2024
2 parents f44d1b8 + 929ea6f commit 86b46fa
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 4 deletions.
4 changes: 4 additions & 0 deletions lib/github-pages-health-check/domain.rb
Original file line number Diff line number Diff line change
Expand Up @@ -245,13 +245,17 @@ def cname_to_github_user_domain?

# Check if the CNAME points to a Domain that points to pages
# e.g. CNAME -> Domain -> Pages
# rubocop:disable Metrics/AbcSize
def cname_to_domain_to_pages?
return false unless dns?

a_record_to_pages = dns.select { |d| d.type == Dnsruby::Types::A && d.name.to_s == host }.first

return false unless a_record_to_pages && cname? && !cname_to_pages_dot_github_dot_com? && @www_cname

CURRENT_IP_ADDRESSES.include?(a_record_to_pages.address.to_s.downcase)
end
# rubocop:enable Metrics/AbcSize

# Is the given domain a CNAME to pages.github.(io|com)
# instead of being CNAME'd to the user's subdomain?
Expand Down
2 changes: 1 addition & 1 deletion lib/github-pages-health-check/version.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@

module GitHubPages
module HealthCheck
VERSION = "1.18.4"
VERSION = "1.18.5"
end
end
6 changes: 3 additions & 3 deletions spec/github_pages_health_check/domain_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -671,7 +671,7 @@
end
end

context "Protocol redirections" do
context "Protocol redirections", :retry => 3, :retry_wait => 1 do
before do
@out = []

Expand Down Expand Up @@ -724,7 +724,7 @@ def stop
@servers.each(&:stop)
end

it "it does not follow anything other than http/https by default", :retry => 3 do
it "it does not follow anything other than http/https by default" do
Typhoeus.get(
"http://localhost:#{@servers[1].port}",
GitHubPages::HealthCheck.typhoeus_options
Expand All @@ -733,7 +733,7 @@ def stop
expect(@out).to_not include("HIT #{@servers[0].port}")
end

it "it follows ftp if requested (negative test)", :retry => 3 do
it "it follows ftp if requested (negative test)" do
Typhoeus.get(
"http://localhost:#{@servers[1].port}",
GitHubPages::HealthCheck.typhoeus_options.merge(:redir_protocols => %i[http https ftp])
Expand Down

0 comments on commit 86b46fa

Please sign in to comment.