Skip to content

Commit

Permalink
Merge pull request #1878 from Sild/snippets-SnippetFileContent-use-Pa…
Browse files Browse the repository at this point in the history
…thEncode

The snippets API was failing due to improper URL encoding of the filename parameter
  • Loading branch information
svanharmelen committed Feb 10, 2024
2 parents d89a43d + f80127d commit b61ed28
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions snippets.go
Expand Up @@ -20,7 +20,6 @@ import (
"bytes"
"fmt"
"net/http"
"net/url"
"time"
)

Expand Down Expand Up @@ -136,7 +135,7 @@ func (s *SnippetsService) SnippetContent(snippet int, options ...RequestOptionFu
// GitLab API docs:
// https://docs.gitlab.com/ee/api/snippets.html#snippet-repository-file-content
func (s *SnippetsService) SnippetFileContent(snippet int, ref, filename string, options ...RequestOptionFunc) ([]byte, *Response, error) {
filepath := url.QueryEscape(filename)
filepath := PathEscape(filename)
u := fmt.Sprintf("snippets/%d/files/%s/%s/raw", snippet, ref, filepath)

req, err := s.client.NewRequest(http.MethodGet, u, nil, options)
Expand Down

0 comments on commit b61ed28

Please sign in to comment.