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

Commit

Permalink
fix(commands/api): replace :id placeholder with project ID
Browse files Browse the repository at this point in the history
The `:id` placeholder in the api command is replaced by the project ID which makes sense instead of the URL encoded path.

Closes #657
  • Loading branch information
profclems committed Mar 22, 2021
1 parent 4dd9ee9 commit dc23620
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion commands/api/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -357,7 +357,15 @@ func fillPlaceholders(value string, opts *ApiOptions) (string, error) {

filled := placeholderRE.ReplaceAllStringFunc(value, func(m string) string {
switch m {
case ":group/:namespace/:repo", ":fullpath", ":id":
case ":id":
h, _ := opts.HttpClient()
baseProject, e := api.GetProject(h, baseRepo.FullName())
if e == nil && baseProject != nil {
return string(rune(baseProject.ID))
}
err = e
return ""
case ":group/:namespace/:repo", ":fullpath":
return url.PathEscape(baseRepo.FullName())
case ":namespace/:repo":
return url.PathEscape(baseRepo.RepoNamespace() + "/" + baseRepo.RepoName())
Expand Down

0 comments on commit dc23620

Please sign in to comment.