## Description Repo `--prefix` values should be normalized with a trailing `/` ## Type of change <!--- Please check the type of change your PR introduces: ---> - [ ] 🌻 Feature - [x] 🐛 Bugfix - [ ] 🗺️ Documentation - [ ] 🤖 Test - [ ] 💻 CI/Deployment - [ ] 🐹 Trivial/Minor ## Issue(s) * Fixes #1152 ## Test Plan <!-- How will this be tested prior to merging.--> - [] 💪 Manual - [x] ⚡ Unit test - [ ] 💚 E2E
26 lines
642 B
Go
26 lines
642 B
Go
package common
|
|
|
|
import "strings"
|
|
|
|
// NormalizeBuckets ensures that bucket names are cleaned and
|
|
// standardized according to the downstream needs of minio.
|
|
//
|
|
// Any url prefixing to location the bucket (ex: s3://bckt)
|
|
// will be removed, leaving only the bucket name (bckt).
|
|
// Corso should only utilize or store the normalized name.
|
|
func NormalizeBucket(b string) string {
|
|
return strings.TrimPrefix(b, "s3://")
|
|
}
|
|
|
|
// NormalizePrefix ensures that a bucket prefix is always treated as
|
|
// object store folder prefix.
|
|
func NormalizePrefix(p string) string {
|
|
tp := strings.TrimRight(p, "/")
|
|
|
|
if len(tp) > 0 {
|
|
tp = tp + "/"
|
|
}
|
|
|
|
return tp
|
|
}
|