Skip to content

Commit 724c708

Browse files
authored
fix slash issue in build name, number in rbc (#1405)
1 parent ab34cf3 commit 724c708

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

common/spec/specfiles.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import (
77
clientutils "github.com/jfrog/jfrog-client-go/utils"
88
"github.com/jfrog/jfrog-client-go/utils/errorutils"
99
"github.com/jfrog/jfrog-client-go/utils/io/fileutils"
10+
"strings"
1011
)
1112

1213
type SpecFiles struct {
@@ -43,7 +44,10 @@ func CreateSpecFromBuildNameNumberAndProject(buildName, buildNumber, projectKey
4344
return nil, errorutils.CheckErrorf("build name and build number must be provided")
4445
}
4546

46-
buildString := buildName + "/" + buildNumber
47+
escapedBuildName := strings.ReplaceAll(buildName, "/", "\\/")
48+
escapedBuildNumber := strings.ReplaceAll(buildNumber, "/", "\\/")
49+
50+
buildString := escapedBuildName + "/" + escapedBuildNumber
4751
specFile := &SpecFiles{
4852
Files: []File{
4953
{

common/spec/specfiles_test.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,4 +45,13 @@ func TestCreateSpecFromBuildNameAndNumber(t *testing.T) {
4545
assert.Nil(t, spec)
4646
assert.EqualError(t, err, "build name and build number must be provided")
4747
})
48+
49+
t.Run("Build Name and Number with Slashes", func(t *testing.T) {
50+
spec, err := CreateSpecFromBuildNameNumberAndProject("my/build/name", "1/2/3", "test")
51+
52+
assert.NoError(t, err)
53+
assert.NotNil(t, spec)
54+
assert.Equal(t, "my\\/build\\/name/1\\/2\\/3", spec.Files[0].Build)
55+
assert.Equal(t, "test", spec.Files[0].Project)
56+
})
4857
}

0 commit comments

Comments
 (0)