chore: Refactor: can short-circuit handling of paths that start with MAIN_SEPARATOR, no matter what MAIN_SEPARATOR is

This commit is contained in:
Chris Hennick 2024-05-03 15:01:43 -07:00
parent 2adbbccb82
commit 74e76a94ca
No known key found for this signature in database
GPG key ID: DA47AABA4961C509

View file

@ -219,7 +219,7 @@ impl Zip64CentralDirectoryEnd {
pub(crate) fn path_to_string<T: AsRef<Path>>(path: T) -> String {
let mut maybe_original = None;
if let Some(original) = path.as_ref().to_str() {
if (MAIN_SEPARATOR == '/' || !original.contains(MAIN_SEPARATOR))
if (MAIN_SEPARATOR == '/' || !original[1..].contains(MAIN_SEPARATOR))
&& !original.ends_with('.')
&& !original.starts_with(['.', MAIN_SEPARATOR])
&& !original.starts_with(['.', '.', MAIN_SEPARATOR])