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
Add literal colon support (#1432) #2857
base: master
Are you sure you want to change the base?
Conversation
c1585c2
to
2e6a3ff
Compare
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #2857 +/- ##
==========================================
+ Coverage 99.21% 99.37% +0.15%
==========================================
Files 42 43 +1
Lines 3182 2711 -471
==========================================
- Hits 3157 2694 -463
+ Misses 17 9 -8
Partials 8 8
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
464c884
to
ed0a30c
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Still need to optimize and adjust, why define some routing rules like \?
The feature included in this PR is not about defining rule like Please refer to issue #1432 for more details |
02a7101
to
6f0bdd0
Compare
@daheige Thanks a lot 👍 🙏 ! |
Hi @thinkerou wondering if you can have a look and approve the PR for the next release. Many thanks 🙏 |
I will take it asap. |
f := func(u string) { | ||
router.GET(u, func(c *Context) { c.String(http.StatusOK, u) }) | ||
} | ||
f("/r/r\\:r") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should probably add a test case for \:r
as well, which should not result in expected behaviour.
f("/r/r/\:r")
for start, c := range []byte(path) { | ||
if escapeColon { | ||
if c == ':' { | ||
escapeColon = false |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What about a case of \\foo:
? escapeColon
would stay true after escape character until colon is reached. It's probably not expected behaviour. It should try to escape next character by the rules. This case is also not covered with test.
Implement literal colon support using the approach described in #1432