mirror of
https://github.com/minio/minio.git
synced 2025-11-20 18:06:10 -05:00
Use const slashSeparator instead of "/" everywhere (#8028)
This commit is contained in:
@@ -51,7 +51,7 @@ const (
|
||||
// Multipart meta prefix.
|
||||
mpartMetaPrefix = "multipart"
|
||||
// MinIO Multipart meta prefix.
|
||||
minioMetaMultipartBucket = minioMetaBucket + "/" + mpartMetaPrefix
|
||||
minioMetaMultipartBucket = minioMetaBucket + SlashSeparator + mpartMetaPrefix
|
||||
// MinIO Tmp meta prefix.
|
||||
minioMetaTmpBucket = minioMetaBucket + "/tmp"
|
||||
// DNS separator (period), used for bucket name validation.
|
||||
@@ -131,12 +131,12 @@ func IsValidBucketName(bucket string) bool {
|
||||
//
|
||||
// - Backslash ("\")
|
||||
//
|
||||
// additionally minio does not support object names with trailing "/".
|
||||
// additionally minio does not support object names with trailing SlashSeparator.
|
||||
func IsValidObjectName(object string) bool {
|
||||
if len(object) == 0 {
|
||||
return false
|
||||
}
|
||||
if hasSuffix(object, slashSeparator) {
|
||||
if hasSuffix(object, SlashSeparator) {
|
||||
return false
|
||||
}
|
||||
return IsValidObjectPrefix(object)
|
||||
@@ -168,7 +168,7 @@ func checkObjectNameForLengthAndSlash(bucket, object string) error {
|
||||
}
|
||||
}
|
||||
// Check for slash as prefix in object name
|
||||
if hasPrefix(object, slashSeparator) {
|
||||
if hasPrefix(object, SlashSeparator) {
|
||||
return ObjectNamePrefixAsSlash{
|
||||
Bucket: bucket,
|
||||
Object: object,
|
||||
@@ -177,20 +177,20 @@ func checkObjectNameForLengthAndSlash(bucket, object string) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
// Slash separator.
|
||||
const slashSeparator = "/"
|
||||
// SlashSeparator - slash separator.
|
||||
const SlashSeparator = "/"
|
||||
|
||||
// retainSlash - retains slash from a path.
|
||||
func retainSlash(s string) string {
|
||||
return strings.TrimSuffix(s, slashSeparator) + slashSeparator
|
||||
return strings.TrimSuffix(s, SlashSeparator) + SlashSeparator
|
||||
}
|
||||
|
||||
// pathJoin - like path.Join() but retains trailing "/" of the last element
|
||||
// pathJoin - like path.Join() but retains trailing SlashSeparator of the last element
|
||||
func pathJoin(elem ...string) string {
|
||||
trailingSlash := ""
|
||||
if len(elem) > 0 {
|
||||
if hasSuffix(elem[len(elem)-1], slashSeparator) {
|
||||
trailingSlash = "/"
|
||||
if hasSuffix(elem[len(elem)-1], SlashSeparator) {
|
||||
trailingSlash = SlashSeparator
|
||||
}
|
||||
}
|
||||
return path.Join(elem...) + trailingSlash
|
||||
@@ -292,7 +292,7 @@ func isStringEqual(s1 string, s2 string) bool {
|
||||
|
||||
// Ignores all reserved bucket names or invalid bucket names.
|
||||
func isReservedOrInvalidBucket(bucketEntry string, strict bool) bool {
|
||||
bucketEntry = strings.TrimSuffix(bucketEntry, slashSeparator)
|
||||
bucketEntry = strings.TrimSuffix(bucketEntry, SlashSeparator)
|
||||
if strict {
|
||||
if err := s3utils.CheckValidBucketNameStrict(bucketEntry); err != nil {
|
||||
return true
|
||||
|
||||
Reference in New Issue
Block a user