Skip to content
This repository has been archived by the owner on Jul 12, 2022. It is now read-only.

[FIX] trailing slashes removed #166

Merged
merged 2 commits into from
Jun 17, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ tags
[._]*.un~

### VisualStudioCode ###
.vscode/*
.vscode/
!.vscode/settings.json
!.vscode/tasks.json
!.vscode/launch.json
Expand Down
3 changes: 3 additions & 0 deletions pkg/server/setter.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"errors"
"fmt"
"net/http"
"strings"

"github.com/ZupIT/ritchie-cli/pkg/file/fileutil"
"github.com/ZupIT/ritchie-cli/pkg/validator"
Expand Down Expand Up @@ -48,6 +49,8 @@ func (s SetterManager) Set(cfg Config) error {
return fmt.Errorf(ServerErrPattern, cfg.URL, resp.Status)
}

cfg.URL = strings.TrimRight(cfg.URL, "/")

b, err := json.Marshal(cfg)
if err != nil {
return err
Expand Down
9 changes: 8 additions & 1 deletion pkg/server/setter_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,13 @@ func TestSet(t *testing.T) {
err: validator.ErrInvalidURL,
},
},
{
name: "trailing slash on serverURL",
in: in{cfg: Config{Organization: "org", URL: fmt.Sprintf("%s/", srvURL)}, hc: http.DefaultClient},
out: out{
status: 200,
},
},
{
name: "valid serverURL",
in: in{cfg: Config{Organization: "org", URL: srvURL}, hc: http.DefaultClient},
Expand Down Expand Up @@ -127,4 +134,4 @@ func mockServer(status int) *httptest.Server {
srv.Start()

return srv
}
}