Skip to content

Commit 4f2bb98

Browse files
authored
Merge pull request #172 from github/no-regex-🧠
Simplify github_domain? check + add test
2 parents f1bed34 + 7f08daa commit 4f2bb98

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

lib/github-pages-health-check/domain.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -283,7 +283,7 @@ def pages_dot_github_dot_com?
283283

284284
# Is this domain owned by GitHub?
285285
def github_domain?
286-
!!host.match(/(\A|\.)github\.com\.?\z/i)
286+
host.downcase.eql?("github.com") || host.downcase.end_with?(".github.com")
287287
end
288288

289289
# Is the host our Fastly CNAME?

spec/github_pages_health_check/domain_spec.rb

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -535,6 +535,14 @@
535535
end
536536
end
537537

538+
context "not github domains" do
539+
let(:domain) { "somethinggithub.com" }
540+
541+
it "knows if the domain is not a github domain" do
542+
expect(subject).to_not be_a_github_domain
543+
end
544+
end
545+
538546
context "fastly domain" do
539547
let(:domain) { "github.map.fastly.net" }
540548

0 commit comments

Comments
 (0)