8
8
"bytes"
9
9
"context"
10
10
"fmt"
11
+ "net/url"
11
12
12
13
"github.com/drone/go-scm/scm"
13
14
)
@@ -17,7 +18,8 @@ type contentService struct {
17
18
}
18
19
19
20
func (s * contentService ) Find (ctx context.Context , repo , path , ref string ) (* scm.Content , * scm.Response , error ) {
20
- endpoint := fmt .Sprintf ("/2.0/repositories/%s/src/%s/%s" , repo , ref , path )
21
+ urlEncodedRef := url .QueryEscape (ref )
22
+ endpoint := fmt .Sprintf ("/2.0/repositories/%s/src/%s/%s" , repo , urlEncodedRef , path )
21
23
out := new (bytes.Buffer )
22
24
res , err := s .client .do (ctx , "GET" , endpoint , nil , out )
23
25
content := & scm.Content {
@@ -27,7 +29,7 @@ func (s *contentService) Find(ctx context.Context, repo, path, ref string) (*scm
27
29
if err != nil {
28
30
return content , res , err
29
31
}
30
- metaEndpoint := fmt .Sprintf ("/2.0/repositories/%s/src/%s/%s?format=meta" , repo , ref , path )
32
+ metaEndpoint := fmt .Sprintf ("/2.0/repositories/%s/src/%s/%s?format=meta" , repo , urlEncodedRef , path )
31
33
metaOut := new (metaContent )
32
34
metaRes , metaErr := s .client .do (ctx , "GET" , metaEndpoint , nil , metaOut )
33
35
if metaErr == nil {
0 commit comments