You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@dubbo.apache.org by al...@apache.org on 2025/11/19 03:46:25 UTC

(dubbo-go) branch develop updated: feat: Allow using group/version wildcards when the interface matches exactly (#3080)

This is an automated email from the ASF dual-hosted git repository.

alexstocks pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/dubbo-go.git


The following commit(s) were added to refs/heads/develop by this push:
     new 029e040ba feat: Allow using group/version wildcards when the interface matches exactly (#3080)
029e040ba is described below

commit 029e040ba9d5d1a6a038264497457eee67682d6f
Author: Akashisang <15...@users.noreply.github.com>
AuthorDate: Wed Nov 19 11:46:19 2025 +0800

    feat: Allow using group/version wildcards when the interface matches exactly (#3080)
    
    * feat: Allow using group/version wildcards when the interface matches exactly
    
    * fix the format error
---
 common/url.go      |  9 +++++++--
 common/url_test.go | 27 ++++++++++++++++++++++++---
 2 files changed, 31 insertions(+), 5 deletions(-)

diff --git a/common/url.go b/common/url.go
index af6e68b08..f90031b98 100644
--- a/common/url.go
+++ b/common/url.go
@@ -477,8 +477,13 @@ func ParseServiceKey(serviceKey string) (string, string, string) {
 
 // IsAnyCondition judges if is any condition
 func IsAnyCondition(intf, group, version string, serviceURL *URL) bool {
-	return intf == constant.AnyValue && (group == constant.AnyValue ||
-		group == serviceURL.Group()) && (version == constant.AnyValue || version == serviceURL.Version())
+	matchCondition := func(pattern, actual string) bool {
+		return pattern == constant.AnyValue || pattern == actual
+	}
+
+	return matchCondition(intf, serviceURL.Service()) &&
+		matchCondition(group, serviceURL.Group()) &&
+		matchCondition(version, serviceURL.Version())
 }
 
 // ColonSeparatedKey
diff --git a/common/url_test.go b/common/url_test.go
index 5ee5197e2..2026c82e4 100644
--- a/common/url_test.go
+++ b/common/url_test.go
@@ -519,8 +519,9 @@ func TestIsAnyCondition(t *testing.T) {
 		serviceURL *URL
 	}
 	serviceURL, _ := NewURL(GetLocalIp()+":0", WithProtocol("admin"), WithParams(url.Values{
-		constant.GroupKey:   {"group"},
-		constant.VersionKey: {"version"},
+		constant.GroupKey:     {"group"},
+		constant.VersionKey:   {"version"},
+		constant.InterfaceKey: {"intf"},
 	}))
 	tests := []struct {
 		name string
@@ -555,7 +556,7 @@ func TestIsAnyCondition(t *testing.T) {
 				version:    constant.AnyValue,
 				serviceURL: serviceURL,
 			},
-			want: false,
+			want: true,
 		},
 		{
 			name: "test4",
@@ -567,6 +568,26 @@ func TestIsAnyCondition(t *testing.T) {
 			},
 			want: false,
 		},
+		{
+			name: "test5",
+			args: args{
+				intf:       "intf",
+				group:      "group",
+				version:    constant.AnyValue,
+				serviceURL: serviceURL,
+			},
+			want: true,
+		},
+		{
+			name: "test6",
+			args: args{
+				intf:       "intf",
+				group:      constant.AnyValue,
+				version:    "version1",
+				serviceURL: serviceURL,
+			},
+			want: false,
+		},
 	}
 	for _, tt := range tests {
 		t.Run(tt.name, func(t *testing.T) {