From d6b2d53249991b0366c81a230ea97fc78bc0c70f Mon Sep 17 00:00:00 2001 From: Edward Shen Date: Sun, 16 Jan 2022 19:40:57 -0800 Subject: [PATCH] Only keep filename for cli filename hint --- cli/src/main.rs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/cli/src/main.rs b/cli/src/main.rs index 100431f..82a9d46 100644 --- a/cli/src/main.rs +++ b/cli/src/main.rs @@ -151,8 +151,12 @@ fn handle_upload( } if !no_file_name_hint { - if let Some(path) = path { - fragment = fragment.file_name(path.to_string_lossy().to_string()); + let file_name = path.and_then(|path| { + path.file_name() + .map(|str| str.to_string_lossy().to_string()) + }); + if let Some(file_name) = file_name { + fragment = fragment.file_name(file_name); } }