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
case insensitivity #2064
base: master
Are you sure you want to change the base?
case insensitivity #2064
Conversation
@ffhelicopter Can you help to resolve the conflicts? |
move to 1.x milestones. |
When to release this version |
Codecov Report
@@ Coverage Diff @@
## master #2064 +/- ##
==========================================
+ Coverage 98.63% 98.83% +0.19%
==========================================
Files 41 40 -1
Lines 2349 2225 -124
==========================================
- Hits 2317 2199 -118
+ Misses 18 14 -4
+ Partials 14 12 -2
Continue to review full report at Codecov.
|
I think we can't merge this feature since of another framework like result:
source code func BenchmarkLowercaseString(B *testing.B) {
B.ReportAllocs()
B.ResetTimer()
s := strings.Repeat("foo_Bar", 64)
f := strings.Repeat("Foo_Bar", 64)
for i := 0; i < B.N; i++ {
_ = strings.ToLower(s) == strings.ToLower(f)
}
}
func BenchmarkLowercaseBytes(B *testing.B) {
B.ReportAllocs()
B.ResetTimer()
s := strings.Repeat("foo_Bar", 64)
f := strings.Repeat("Foo_Bar", 64)
for i := 0; i < B.N; i++ {
_ = bytes.EqualFold([]byte(s), []byte(f))
}
} |
Maybe we can use case-insensitive comparison as a backup, something like this:
In this way, we can support case-insensitive feature without costing too much. |
The Gin framework is case sensitive for URLs, but the URL is not case sensitive in the browser. For a better user experience, it is recommended to optimize the URL case sensitivity, and use the lowercase path uniformly when registering the handler. Considering the case of URI parameters, you can't directly convert the URL to lowercase or uppercase in the program. You can convert it to lowercase in the node.getValue() method and compare it to achieve case insensitivity.
For example, the more complex URI below:
When this feature is implemented. Although the user and go42 in the above program are lowercase when registering, when accessing the following two URLs, they can be accessed normally and the page is rendered.
Localhost:8080/user/Rob/Pike/Go42
Localhost:8080/uSer/Rob/Pike/Go42