Skip to main content

parent_prefix

Function parent_prefix 

Source
pub fn parent_prefix(key: &str) -> String
Expand description

Return the parent prefix of an S3 key.

The parent prefix is everything up to and including the last / before the final component (object name or sub-folder name). When the key contains no / the root prefix "" is returned.

ยงExamples

use brows3r_lib::s3::object::parent_prefix;
assert_eq!(parent_prefix("a/b/c.txt"), "a/b/");
assert_eq!(parent_prefix("file.txt"),  "");
assert_eq!(parent_prefix("dir/"),      "");
assert_eq!(parent_prefix("a/b/"),      "a/");
assert_eq!(parent_prefix(""),          "");