You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@devlake.apache.org by ab...@apache.org on 2023/05/26 11:39:00 UTC
[incubator-devlake] branch main updated: feat: make sure the connection endpoint ends with "/" (#5292)
This is an automated email from the ASF dual-hosted git repository.
abeizn pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/incubator-devlake.git
The following commit(s) were added to refs/heads/main by this push:
new d8f9abbb5 feat: make sure the connection endpoint ends with "/" (#5292)
d8f9abbb5 is described below
commit d8f9abbb5632d3af027100e81ccd8be0bf9c8610
Author: Bird <16...@qq.com>
AuthorDate: Fri May 26 19:38:55 2023 +0800
feat: make sure the connection endpoint ends with "/" (#5292)
---
backend/helpers/pluginhelper/api/connection.go | 10 ++++++++--
backend/plugins/github/api/connection.go | 3 ++-
2 files changed, 10 insertions(+), 3 deletions(-)
diff --git a/backend/helpers/pluginhelper/api/connection.go b/backend/helpers/pluginhelper/api/connection.go
index bb05074df..b39d3a1d6 100644
--- a/backend/helpers/pluginhelper/api/connection.go
+++ b/backend/helpers/pluginhelper/api/connection.go
@@ -18,6 +18,8 @@ limitations under the License.
package api
import (
+ "strings"
+
"github.com/apache/incubator-devlake/core/models/common"
)
@@ -34,9 +36,13 @@ type RestConnection struct {
RateLimitPerHour int `comment:"api request rate limit per hour" json:"rateLimitPerHour"`
}
-// GetEndpoint returns the API endpoint of the connection
+// GetEndpoint returns the API endpoint of the connection, which always ends with "/"
func (rc RestConnection) GetEndpoint() string {
- return rc.Endpoint
+ // make sure the endpoint ends with "/"
+ if rc.Endpoint == "" || strings.HasSuffix(rc.Endpoint, "/") {
+ return rc.Endpoint
+ }
+ return rc.Endpoint + "/"
}
// GetProxy returns the proxy for the connection
diff --git a/backend/plugins/github/api/connection.go b/backend/plugins/github/api/connection.go
index 74b28a7bd..55d97af60 100644
--- a/backend/plugins/github/api/connection.go
+++ b/backend/plugins/github/api/connection.go
@@ -23,12 +23,13 @@ import (
"net/http"
"strings"
+ "github.com/mitchellh/mapstructure"
+
"github.com/apache/incubator-devlake/core/errors"
"github.com/apache/incubator-devlake/core/plugin"
"github.com/apache/incubator-devlake/helpers/pluginhelper/api"
"github.com/apache/incubator-devlake/plugins/github/models"
"github.com/apache/incubator-devlake/server/api/shared"
- "github.com/mitchellh/mapstructure"
)
var publicPermissions = []string{"repo:status", "repo_deployment", "read:user", "read:org"}