mirror of
https://github.com/rustfs/rustfs.git
synced 2026-08-18 02:33:15 +00:00
fix(window): Compatible with Windows Path (#2691)
Co-authored-by: houseme <housemecn@gmail.com>
This commit is contained in:
@@ -90,7 +90,12 @@ pub fn retain_slash(s: &str) -> String {
|
||||
|
||||
/// Checks if string `s` starts with `prefix` using case-insensitive comparison.
|
||||
pub fn strings_has_prefix_fold(s: &str, prefix: &str) -> bool {
|
||||
s.len() >= prefix.len() && (s[..prefix.len()] == *prefix || s[..prefix.len()].eq_ignore_ascii_case(prefix))
|
||||
if s.starts_with(prefix) {
|
||||
return true;
|
||||
}
|
||||
|
||||
s.get(..prefix.len())
|
||||
.is_some_and(|s_prefix| s_prefix.eq_ignore_ascii_case(prefix))
|
||||
}
|
||||
|
||||
/// Checks if string `s` starts with `prefix`.
|
||||
@@ -875,4 +880,16 @@ mod tests {
|
||||
assert_eq!(bucket, "bucket");
|
||||
assert_eq!(object, "object");
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[cfg(target_os = "windows")]
|
||||
fn test_path_to_bucket_object_with_base_path_handles_unicode_without_panicking() {
|
||||
let (bucket, object) = path_to_bucket_object_with_base_path(
|
||||
"D:\\Github\\rustfs\\target\\volumes\\test1",
|
||||
"s3-test-bucket/中文/日本語/한글-9cd5599a-f8eb-4e24-9df7-32ecd8d8ad1f",
|
||||
);
|
||||
|
||||
assert_eq!(bucket, "s3-test-bucket");
|
||||
assert_eq!(object, "中文/日本語/한글-9cd5599a-f8eb-4e24-9df7-32ecd8d8ad1f");
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user