diff --git a/lib/github-pages-health-check/domain.rb b/lib/github-pages-health-check/domain.rb index 32e2e22..8063dc4 100644 --- a/lib/github-pages-health-check/domain.rb +++ b/lib/github-pages-health-check/domain.rb @@ -356,7 +356,6 @@ def served_by_pages? return unless dns_resolves? @served_by_pages = begin - return false unless response.mock? || response.return_code == :ok return true if response.headers["Server"] == "GitHub.com" # Typhoeus mangles the case of the header, compare insensitively diff --git a/lib/github-pages-health-check/version.rb b/lib/github-pages-health-check/version.rb index 3d580b5..726dc7b 100644 --- a/lib/github-pages-health-check/version.rb +++ b/lib/github-pages-health-check/version.rb @@ -2,6 +2,6 @@ module GitHubPages module HealthCheck - VERSION = "1.17.1" + VERSION = "1.17.2" end end diff --git a/spec/github_pages_health_check/domain_spec.rb b/spec/github_pages_health_check/domain_spec.rb index f57e0a7..5372852 100644 --- a/spec/github_pages_health_check/domain_spec.rb +++ b/spec/github_pages_health_check/domain_spec.rb @@ -483,6 +483,12 @@ allow(subject).to receive(:dns) { [a_packet] } stub_request(:head, domain) .to_return(:status => status, :headers => headers) + + stub_request(:head, "https://githubuniverse.com/") + .to_return(:status => 200, :headers => { :server => "GitHub.com" }) + + stub_request(:head, "https://github.com/login") + .to_return(:status => 200, :headers => { :server => "GitHub.com" }) end context "with the Pages server header" do @@ -507,6 +513,27 @@ expect(subject).to be_served_by_pages end end + + context "an alternate domain" do + let(:domain) { "http://www.githubuniverse.com" } + let(:status) { 301 } + let(:headers) { { :location => "https://githubuniverse.com" } } + before(:each) { allow(subject).to receive(:dns) { [cname_packet] } } + + it "knows about domains that redirect to the primary domain on pages" do + expect(subject).to be_served_by_pages + end + end + + context "a private page" do + let(:domain) { "http://private-page.githubapp.com" } + let(:status) { 302 } + let(:headers) { { :location => "https://github.com/login" } } + + it "considers it valid if it redirects to github.com/login" do + expect(subject).to be_served_by_pages + end + end end context "with a request ID" do