phpcyy commented on code in PR #3160:
URL: https://github.com/apache/dubbo-go/pull/3160#discussion_r2694012374
##########
common/url.go:
##########
@@ -897,18 +921,41 @@ func (c *URL) RangeAttributes(f func(key string, value
any) bool) {
}
func (c *URL) CloneExceptParams(excludeParams *gxset.HashSet) *URL {
- newURL := &URL{}
- if err := copier.Copy(newURL, c); err != nil {
- // this is impossible
- return newURL
- }
- newURL.params = url.Values{}
- c.RangeParams(func(key, value string) bool {
- if !excludeParams.Contains(key) {
+ newURL := &URL{
+ Protocol: c.Protocol,
+ Location: c.Location,
+ Ip: c.Ip,
+ Port: c.Port,
+ PrimitiveURL: c.PrimitiveURL,
+ Path: c.Path,
+ Username: c.Username,
+ Password: c.Password,
+ Methods: append(make([]string, 0), c.Methods...),
+ attributes: make(map[string]any),
+ params: url.Values{},
+ }
+
+ c.RangeParams(
+ func(key, value string) bool {
+ if excludeParams != nil && excludeParams.Contains(key) {
+ return true
+ }
newURL.SetParam(key, value)
- }
- return true
- })
+ return true
+ },
+ )
+
+ c.RangeAttributes(
+ func(key string, value any) bool {
+ newURL.SetAttribute(key, value)
+ return true
+ },
+ )
+
+ if c.SubURL != nil {
+ newURL.SubURL = c.SubURL.Clone()
+ }
+
return newURL
}
Review Comment:
done
--
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]