Skip to content
Snippets Groups Projects
Commit 73f75993 authored by 邹毅贤's avatar 邹毅贤
Browse files

Merge branch 'develop' into feature/addRegistryUnpub

parents d532083b 0365fbb0
No related branches found
No related tags found
No related merge requests found
......@@ -212,9 +212,9 @@ const (
// consumer
CONSUMER = "consumer"
// key of access key id
ACCESS_KEY_ID_KEY = "accessKeyId"
ACCESS_KEY_ID_KEY = ".accessKeyId"
// key of secret access key
SECRET_ACCESS_KEY_KEY = "secretAccessKey"
SECRET_ACCESS_KEY_KEY = ".secretAccessKey"
)
// metadata report
......
......@@ -22,9 +22,8 @@ import (
"strings"
"sync"
)
import (
"github.com/dubbogo/gost/container/set"
gxset "github.com/dubbogo/gost/container/set"
)
import (
......@@ -96,8 +95,24 @@ func getRegistry(regUrl *common.URL) registry.Registry {
func getUrlToRegistry(providerUrl *common.URL, registryUrl *common.URL) *common.URL {
if registryUrl.GetParamBool("simplified", false) {
return providerUrl.CloneWithParams(reserveParams)
} else {
return filterHideKey(providerUrl)
}
}
// filterHideKey filter the parameters that do not need to be output in url(Starting with .)
func filterHideKey(url *common.URL) *common.URL {
//be careful params maps in url is map type
cloneURL := url.Clone()
removeSet := gxset.NewSet()
for k, _ := range cloneURL.GetParams() {
if strings.HasPrefix(k, ".") {
removeSet.Add(k)
}
}
return providerUrl
cloneURL.RemoveParams(removeSet)
return cloneURL
}
func (proto *registryProtocol) initConfigurationListeners() {
......
......@@ -284,3 +284,12 @@ func TestExportWithApplicationConfig(t *testing.T) {
v2, _ := regProtocol.bounds.Load(getCacheKey(newUrl))
assert.NotNil(t, v2)
}
func TestGetProviderUrlWithHideKey(t *testing.T) {
url, _ := common.NewURL("dubbo://127.0.0.1:1111?a=a1&b=b1&.c=c1&.d=d1&e=e1&protocol=registry")
providerUrl := getUrlToRegistry(&url, &url)
assert.NotContains(t, providerUrl.GetParams(), ".c")
assert.NotContains(t, providerUrl.GetParams(), ".d")
assert.Contains(t, providerUrl.GetParams(), "a")
}
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment