iceberg_rust_spec/
util.rs1use url::Url;
5
6pub fn strip_prefix(path: &str) -> String {
21 match Url::parse(path) {
22 Ok(url) => String::from(url.path()),
23 Err(_) => String::from(path),
24 }
25}
26
27#[cfg(test)]
28mod tests {
29 use crate::util::strip_prefix;
30 #[test]
31 fn strip_prefix_behaves_as_expected() {
32 assert_eq!(strip_prefix("/a/b"), "/a/b");
33 assert_eq!(strip_prefix("memory:///a/b"), "/a/b");
34 assert_eq!(strip_prefix("file:///a/b"), "/a/b");
35 assert_eq!(strip_prefix("s3://bucket/a/b"), "/a/b");
36 assert_eq!(strip_prefix("gs://bucket/a/b"), "/a/b");
37 assert_eq!(strip_prefix("az://bucket/a/b"), "/a/b");
38 }
39}