Skip to content

Commit

Permalink
🐛 Fix url escaping database name
Browse files Browse the repository at this point in the history
  • Loading branch information
mehrdadep authored and gesellix committed Nov 14, 2020
1 parent e48f0c3 commit d1b982a
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
8 changes: 4 additions & 4 deletions couchdb-exporter_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ func TestCouchdbStatsV1Integration(t *testing.T) {
client := lib.NewCouchdbClient(dbUrl, basicAuth, true)
databases := []string{"v1_testdb1", "v1_test/db2"}
for _, db := range databases {
_, err = client.Request("PUT", fmt.Sprintf("%s/%s", client.BaseUri, url.PathEscape(db)), nil)
_, err = client.Request("PUT", fmt.Sprintf("%s/%s", client.BaseUri, url.QueryEscape(db)), nil)
if err != nil {
t.Error(err)
}
Expand Down Expand Up @@ -257,7 +257,7 @@ func TestCouchdbStatsV1Integration(t *testing.T) {
})

for _, db := range databases {
_, err = client.Request("DELETE", fmt.Sprintf("%s/%s", client.BaseUri, url.PathEscape(db)), nil)
_, err = client.Request("DELETE", fmt.Sprintf("%s/%s", client.BaseUri, url.QueryEscape(db)), nil)
if err != nil {
t.Error(err)
}
Expand Down Expand Up @@ -310,7 +310,7 @@ func TestCouchdbStatsV2Integration(t *testing.T) {
client := lib.NewCouchdbClient(dbUrl, basicAuth, true)
databases := []string{"v2_testdb1", "v2_test/db2"}
for _, db := range databases {
_, err = client.Request("PUT", fmt.Sprintf("%s/%s", client.BaseUri, url.PathEscape(db)), nil)
_, err = client.Request("PUT", fmt.Sprintf("%s/%s", client.BaseUri, url.QueryEscape(db)), nil)
if err != nil {
t.Error(err)
}
Expand Down Expand Up @@ -367,7 +367,7 @@ func TestCouchdbStatsV2Integration(t *testing.T) {
})

for _, db := range databases {
_, err = client.Request("DELETE", fmt.Sprintf("%s/%s", client.BaseUri, url.PathEscape(db)), nil)
_, err = client.Request("DELETE", fmt.Sprintf("%s/%s", client.BaseUri, url.QueryEscape(db)), nil)
if err != nil {
t.Error(err)
}
Expand Down
6 changes: 3 additions & 3 deletions lib/couchdb-client.go
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,7 @@ func (c *CouchdbClient) getDatabasesStatsByDbName(databases []string, concurrenc
// scatter
for _, dbName := range databases {
dbName := dbName // rebind for closure to capture the value
escapedDbName := url.PathEscape(dbName)
escapedDbName := url.QueryEscape(dbName)
go func() {
err := semaphore.Acquire()
if err != nil {
Expand Down Expand Up @@ -329,7 +329,7 @@ type viewStats struct {
}

func (c *CouchdbClient) viewStats(isCouchdbV1 bool, dbName string, designDocId string, viewName string) viewStats {
escapedDbName := url.PathEscape(dbName)
escapedDbName := url.QueryEscape(dbName)

query := strings.Join([]string{
"stale=ok",
Expand Down Expand Up @@ -397,7 +397,7 @@ func (c *CouchdbClient) enhanceWithViewUpdateSeq(isCouchdbV1 bool, dbStatsByDbNa
for dbName, dbStats := range dbStatsByDbName {
dbName := dbName // rebind for closure to capture the value
dbStats := dbStats // rebind for closure to capture the value
escapedDbName := url.PathEscape(dbName)
escapedDbName := url.QueryEscape(dbName)
go func() {
err := semaphore.Acquire()
if err != nil {
Expand Down

0 comments on commit d1b982a

Please sign in to comment.