fix: url escape path components
Signed-off-by: Babak K. Shandiz <babakks@github.com>
This commit is contained in:
parent
3ad29588b8
commit
74054c0f71
11 changed files with 41 additions and 31 deletions
|
|
@ -3,6 +3,7 @@ package delete
|
|||
import (
|
||||
"fmt"
|
||||
"net/http"
|
||||
"net/url"
|
||||
|
||||
"github.com/MakeNowJust/heredoc"
|
||||
"github.com/cli/cli/v2/api"
|
||||
|
|
@ -100,13 +101,13 @@ func removeRun(opts *DeleteOptions) error {
|
|||
var host string
|
||||
switch variableEntity {
|
||||
case shared.Organization:
|
||||
path = fmt.Sprintf("orgs/%s/actions/variables/%s", orgName, opts.VariableName)
|
||||
path = fmt.Sprintf("orgs/%s/actions/variables/%s", url.PathEscape(orgName), url.PathEscape(opts.VariableName))
|
||||
host, _ = cfg.Authentication().DefaultHost()
|
||||
case shared.Environment:
|
||||
path = fmt.Sprintf("repos/%s/environments/%s/variables/%s", ghrepo.FullName(baseRepo), envName, opts.VariableName)
|
||||
path = fmt.Sprintf("repos/%s/environments/%s/variables/%s", ghrepo.FullName(baseRepo), url.PathEscape(envName), url.PathEscape(opts.VariableName))
|
||||
host = baseRepo.RepoHost()
|
||||
case shared.Repository:
|
||||
path = fmt.Sprintf("repos/%s/actions/variables/%s", ghrepo.FullName(baseRepo), opts.VariableName)
|
||||
path = fmt.Sprintf("repos/%s/actions/variables/%s", ghrepo.FullName(baseRepo), url.PathEscape(opts.VariableName))
|
||||
host = baseRepo.RepoHost()
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@ import (
|
|||
"errors"
|
||||
"fmt"
|
||||
"net/http"
|
||||
"net/url"
|
||||
|
||||
"github.com/MakeNowJust/heredoc"
|
||||
"github.com/cli/cli/v2/api"
|
||||
|
|
@ -101,13 +102,13 @@ func getRun(opts *GetOptions) error {
|
|||
var host string
|
||||
switch variableEntity {
|
||||
case shared.Organization:
|
||||
path = fmt.Sprintf("orgs/%s/actions/variables/%s", orgName, opts.VariableName)
|
||||
path = fmt.Sprintf("orgs/%s/actions/variables/%s", url.PathEscape(orgName), url.PathEscape(opts.VariableName))
|
||||
host, _ = cfg.Authentication().DefaultHost()
|
||||
case shared.Environment:
|
||||
path = fmt.Sprintf("repos/%s/environments/%s/variables/%s", ghrepo.FullName(baseRepo), envName, opts.VariableName)
|
||||
path = fmt.Sprintf("repos/%s/environments/%s/variables/%s", ghrepo.FullName(baseRepo), url.PathEscape(envName), url.PathEscape(opts.VariableName))
|
||||
host = baseRepo.RepoHost()
|
||||
case shared.Repository:
|
||||
path = fmt.Sprintf("repos/%s/actions/variables/%s", ghrepo.FullName(baseRepo), opts.VariableName)
|
||||
path = fmt.Sprintf("repos/%s/actions/variables/%s", ghrepo.FullName(baseRepo), url.PathEscape(opts.VariableName))
|
||||
host = baseRepo.RepoHost()
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@ package list
|
|||
import (
|
||||
"fmt"
|
||||
"net/http"
|
||||
"net/url"
|
||||
"slices"
|
||||
"strings"
|
||||
"time"
|
||||
|
|
@ -197,12 +198,12 @@ func getRepoVariables(client *http.Client, repo ghrepo.Interface) ([]shared.Vari
|
|||
}
|
||||
|
||||
func getEnvVariables(client *http.Client, repo ghrepo.Interface, envName string) ([]shared.Variable, error) {
|
||||
path := fmt.Sprintf("repos/%s/environments/%s/variables", ghrepo.FullName(repo), envName)
|
||||
path := fmt.Sprintf("repos/%s/environments/%s/variables", ghrepo.FullName(repo), url.PathEscape(envName))
|
||||
return getVariables(client, repo.RepoHost(), path)
|
||||
}
|
||||
|
||||
func getOrgVariables(client *http.Client, host, orgName string, showSelectedRepoInfo bool) ([]shared.Variable, error) {
|
||||
variables, err := getVariables(client, host, fmt.Sprintf("orgs/%s/actions/variables", orgName))
|
||||
variables, err := getVariables(client, host, fmt.Sprintf("orgs/%s/actions/variables", url.PathEscape(orgName)))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue