fix: url escape path components

Signed-off-by: Babak K. Shandiz <babakks@github.com>
This commit is contained in:
Babak K. Shandiz 2026-04-22 15:55:02 +01:00
parent 3ad29588b8
commit 74054c0f71
No known key found for this signature in database
GPG key ID: 9472CAEFF56C742E
11 changed files with 41 additions and 31 deletions

View file

@ -7,6 +7,7 @@ import (
"fmt"
"math/rand"
"net/http"
"net/url"
"strings"
"time"
@ -156,7 +157,7 @@ func createLabel(client *http.Client, repo ghrepo.Interface, opts *createOptions
}
func updateLabel(apiClient *api.Client, repo ghrepo.Interface, opts *editOptions) error {
path := fmt.Sprintf("repos/%s/%s/labels/%s", repo.RepoOwner(), repo.RepoName(), opts.Name)
path := fmt.Sprintf("repos/%s/%s/labels/%s", repo.RepoOwner(), repo.RepoName(), url.PathEscape(opts.Name))
properties := map[string]string{}
if opts.Description != "" {
properties["description"] = opts.Description

View file

@ -3,6 +3,7 @@ package label
import (
"fmt"
"net/http"
"net/url"
"github.com/cli/cli/v2/api"
"github.com/cli/cli/v2/internal/ghrepo"
@ -94,7 +95,7 @@ func deleteRun(opts *deleteOptions) error {
func deleteLabel(client *http.Client, repo ghrepo.Interface, name string) error {
apiClient := api.NewClientFromHTTP(client)
path := fmt.Sprintf("repos/%s/%s/labels/%s", repo.RepoOwner(), repo.RepoName(), name)
path := fmt.Sprintf("repos/%s/%s/labels/%s", repo.RepoOwner(), repo.RepoName(), url.PathEscape(name))
return apiClient.REST(repo.RepoHost(), "DELETE", path, nil, nil)
}