mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2026-11-01 01:40:44 +01:00
s3tables: refactor bucket name validation into single function
Combine length, character, and reserved pattern validation into validateBucketName() which returns descriptive error messages. Keep isValidBucketName() for backward compatibility. This simplifies handler validation and provides better error reporting.
This commit is contained in:
1 parent
fe66d00ab0
commit
d5ce6a4cda
1 file changed
+7
-1
@@ -47,6 +47,12 @@ func parseTableFromARN(arn string) (bucketName, namespace, tableName string, err
|
||||
return "", "", "", fmt.Errorf("invalid table ARN: %s", arn)
|
||||
}
|
||||
|
||||
// Validate bucket name
|
||||
bucketName = matches[1]
|
||||
if err := validateBucketName(bucketName); err != nil {
|
||||
return "", "", "", fmt.Errorf("invalid bucket name in ARN: %v", err)
|
||||
}
|
||||
|
||||
// Namespace is already constrained by the regex; validate it directly.
|
||||
namespace = matches[2]
|
||||
_, err = validateNamespace([]string{namespace})
|
||||
@@ -62,7 +68,7 @@ func parseTableFromARN(arn string) (bucketName, namespace, tableName string, err
|
||||
if _, err := validateTableName(tableNameUnescaped); err != nil {
|
||||
return "", "", "", fmt.Errorf("invalid table name in ARN: %v", err)
|
||||
}
|
||||
return matches[1], namespace, tableNameUnescaped, nil
|
||||
return bucketName, namespace, tableNameUnescaped, nil
|
||||
}
|
||||
|
||||
// Path helpers
|
||||
|
||||
Reference in new issue
Block a user