From 7d75e32ed9fbef898e049d1e79c7618135b3efd1 Mon Sep 17 00:00:00 2001 From: John Spray Date: Thu, 18 Apr 2024 08:00:35 +0100 Subject: [PATCH] add RemotePath::add_trailing_slash -- this is awkward to do by hand --- libs/remote_storage/src/lib.rs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/libs/remote_storage/src/lib.rs b/libs/remote_storage/src/lib.rs index e708854be2..d478599d87 100644 --- a/libs/remote_storage/src/lib.rs +++ b/libs/remote_storage/src/lib.rs @@ -134,6 +134,11 @@ impl RemotePath { pub fn strip_prefix(&self, p: &RemotePath) -> Result<&Utf8Path, std::path::StripPrefixError> { self.0.strip_prefix(&p.0) } + + pub fn add_trailing_slash(&self) -> Self { + // Unwrap safety inputs are guararnteed to be valid UTF-8 + Self(format!("{}/", self.0).try_into().unwrap()) + } } /// We don't need callers to be able to pass arbitrary delimiters: just control