Skip to content

Fix github.com matching #167

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Sep 9, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .github/CODEOWNERS
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Automatically add our team to each pull request in this repo
* @github/pages-reviewers
2 changes: 1 addition & 1 deletion lib/github-pages-health-check/domain.rb
Original file line number Diff line number Diff line change
@@ -283,7 +283,7 @@ def pages_dot_github_dot_com?

# Is this domain owned by GitHub?
def github_domain?
!!host.downcase.end_with?("github.com")
!!host.match(/(\A|\.)github\.com\.?\z/i)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Without a test, it's a bit difficult to know what potential problematic input this also handles. In general regular expressions are much slower in Ruby than string comparisons, but moreover they're a bit harder to audit/grok. I see it matches more cases like github.com. (trailing period) and enforces either strictly github.com or a subdomain thereof, but it's not necessarily clear what other cases you might want to include.

Checking host.downcase.eql?("github.com") || host.downcase.end_with?(".github.com") could be a more direct alternative if you're interested.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👋 Always nice to see you around!

Thanks for the feedback 🙇. Here goes: #172

end

# Is the host our Fastly CNAME?