Improve String Handling for Empty and Whitespace Parameters in Key and Bucket Methods#409
Merged
Merged
Conversation
joneubank
approved these changes
Jun 12, 2024
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
All three code changes introduced the use of the isBlank() method to handle empty strings in different contexts:
getKey and getMetaKey methods: These methods now check if the dir variable is empty. If it is empty, they return only the objectId. Otherwise, they maintain the original behavior of concatenating the directory path and object identifier. This provides more flexibility in handling scenarios where the data might not have a specific directory structure.
getObjectMetaKey method: Similar to the previous change, this method now checks if the dataDir parameter is empty. If it's empty, it creates a key using only the objectId with the ".meta" extension. This allows the method to function even when no directory path is provided.
readBucket method: This method now checks if the prefix parameter is empty. If it's empty, it retrieves all objects from the specified S3 bucket. Otherwise, it continues to filter objects based on the provided prefix. This change offers more control over how you list S3 objects, allowing you to retrieve all objects within a bucket if needed.
In summary, these changes enhance the code's ability to handle empty strings, making it more adaptable to various situations where directory paths or prefixes might be absent.