Skip to content
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

fix(net/ghttp): Server Domain if is empty str, bind handler pattern will add @ which is not expect #4100 #4101

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

elonnzhang
Copy link

if domain != "" {
return pattern + "@" + domain
}
return pattern
Copy link
Member

Choose a reason for hiding this comment

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

It might have something to do with the regular expression at

array, _ := gregex.MatchString(`(.*?)%([A-Z]+):(.+)@(.+)`, k)
The regular expression might better be (.*?)%([A-Z]+):(.+?)@(.+).
You also need commit associated unit testing case for this update.

@houseme houseme requested a review from Copilot March 28, 2025 05:16
Copy link

@Copilot 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 fixes an issue where binding handler patterns would incorrectly include an "@" character when the server domain is an empty string. The changes refactor the string concatenation logic by introducing a helper function that conditionally adds the "@" separator.

  • Replaces inline concatenations with the new helper function patternBindDomain.
  • Updates all handler binding methods to use the helper function.
  • Introduces patternBindDomain to conditionally format the handler pattern.
Comments suppressed due to low confidence (2)

net/ghttp/ghttp_server_domain.go:170

  • [nitpick] Consider adding a brief documentation comment for the helper function 'patternBindDomain' to explain its behavior, especially its handling of empty domain strings.
func patternBindDomain(pattern, domain string) string {

net/ghttp/ghttp_server_domain.go:170

  • Consider adding unit tests for 'patternBindDomain', ensuring that the function behaves correctly with both empty and non-empty domain strings.
func patternBindDomain(pattern, domain string) string {

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