Similarityoung commented on code in PR #1074:
URL: https://github.com/apache/dubbo-go-pixiu/pull/1074#discussion_r4462297705
##########
pkg/common/util/stringutil/stringutil.go:
##########
@@ -68,29 +68,28 @@ func IsMatchAll(key string) bool {
}
func GetTrieKey(method string, path string) string {
- // "http://localhost:8882/api/v1/test-dubbo/user?name=tc/"
+ // Query delimiters must not be interpreted as authority or path
delimiters.
+ path, _, _ = strings.Cut(path, "?")
ret := ""
if strings.Contains(path, constant.ProtocolSlash) {
path = path[strings.Index(path,
constant.ProtocolSlash)+len(constant.ProtocolSlash):]
- path = path[strings.Index(path, constant.PathSlash)+1:]
+ if slash := strings.Index(path, constant.PathSlash); slash >= 0
{
+ path = path[slash+1:]
+ } else {
+ path = ""
+ }
Review Comment:
The `://` heuristic is applied to the whole input, so a valid relative path
such as `/proxy/http://example.com` is still treated as an absolute URL. With
the new no-slash fallback this now maps to the root key `GET` (previously it
mapped to `GET/example.com`), so if a root route is configured the request can
be routed to the wrong action. Could we anchor scheme detection to a leading
scheme (or use `url.Parse`/`u.IsAbs()`) and add a regression test for a path
containing `://`?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]