Skip to content

Do not use EqualFold when checking u.Host#4496

Open
nikola-jokic wants to merge 1 commit into
masterfrom
nikola-jokic/use-strong-equal
Open

Do not use EqualFold when checking u.Host#4496
nikola-jokic wants to merge 1 commit into
masterfrom
nikola-jokic/use-strong-equal

Conversation

@nikola-jokic
Copy link
Copy Markdown
Collaborator

No description provided.

Copilot AI review requested due to automatic review settings May 12, 2026 22:09
@github-actions
Copy link
Copy Markdown
Contributor

Hello! Thank you for your contribution.

Please review our contribution guidelines to understand the project's testing and code conventions.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR changes hosted GitHub host detection and API host routing by replacing strings.EqualFold checks on url.URL.Host with case-sensitive equality comparisons.

Changes:

  • Replaced strings.EqualFold("www.github.com", c.ConfigURL.Host) with c.ConfigURL.Host == "www.github.com" in GitHubAPIURL.
  • Replaced strings.EqualFold host matching in isHostedGitHubURL with u.Host == ... comparisons.
Comments suppressed due to low confidence (1)

github/actions/actions.go:108

  • These hosted GitHub checks are now case-sensitive on u.Host; hostnames are case-insensitive and url.Parse does not guarantee lowercase. This can misclassify hosted URLs and change the API base path/host selection. Consider comparing against a normalized hostname (e.g., strings.ToLower(u.Hostname())) rather than raw u.Host.
	return u.Host == "github.com" ||
		u.Host == "www.github.com" ||
		u.Host == "github.localhost" ||
		strings.HasSuffix(u.Host, ".ghe.com")

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread github/actions/actions.go
Comment on lines 85 to 90
result.Host = fmt.Sprintf("api.%s", c.ConfigURL.Host)
result.Path = ""

if strings.EqualFold("www.github.com", c.ConfigURL.Host) {
if c.ConfigURL.Host == "www.github.com" {
// re-routing www.github.com to api.github.com
result.Host = "api.github.com"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants