mirror of
https://github.com/harness/drone.git
synced 2025-05-10 00:11:43 +08:00
fix: [CODE-3440]: add fix for go get in cut out terminated path (#3618)
* fix: [CODE-3440]: add fix for go get in cut out terminated path
This commit is contained in:
parent
d3261ebc20
commit
6b521d3422
@ -270,6 +270,10 @@ func regexPathTerminatedWithMarker(
|
|||||||
// case 2: xxxxxxxxxxxxxxxxxxxxxxxxM/ (M is at the end and it should have a / after it)
|
// case 2: xxxxxxxxxxxxxxxxxxxxxxxxM/ (M is at the end and it should have a / after it)
|
||||||
// case 3: xxxxxxxxxxxxxxxxxxxxxxxxxM (M is at the end).
|
// case 3: xxxxxxxxxxxxxxxxxxxxxxxxxM (M is at the end).
|
||||||
func cutOutTerminatedPath(subPath string, marker string) (string, bool) {
|
func cutOutTerminatedPath(subPath string, marker string) (string, bool) {
|
||||||
|
// base case of marker being empty
|
||||||
|
if marker == "" {
|
||||||
|
return subPath, true
|
||||||
|
}
|
||||||
endsWithSlash := strings.HasSuffix(marker, "/")
|
endsWithSlash := strings.HasSuffix(marker, "/")
|
||||||
if !endsWithSlash {
|
if !endsWithSlash {
|
||||||
marker += "/"
|
marker += "/"
|
||||||
|
@ -252,6 +252,13 @@ func TestCutOutTerminatedPath(t *testing.T) {
|
|||||||
expectedPath: "",
|
expectedPath: "",
|
||||||
expectedFound: true,
|
expectedFound: true,
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
name: "empty marker",
|
||||||
|
subPath: "/foo/bar",
|
||||||
|
marker: "",
|
||||||
|
expectedPath: "/foo/bar",
|
||||||
|
expectedFound: true,
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, tt := range tests {
|
for _, tt := range tests {
|
||||||
|
Loading…
Reference in New Issue
Block a user