Compare commits

..

2 commits

Author SHA1 Message Date
d6b2d53249
Only keep filename for cli filename hint 2022-01-16 19:40:57 -08:00
f1ad421777
Clippy 2022-01-16 19:40:14 -08:00
3 changed files with 14 additions and 7 deletions

View file

@ -17,16 +17,20 @@ impl Builder {
}
}
pub fn needs_password(mut self) -> Self {
pub const fn needs_password(mut self) -> Self {
self.needs_password = true;
self
}
// False positive
#[allow(clippy::missing_const_for_fn)]
pub fn file_name(mut self, name: String) -> Self {
self.file_name = Some(name);
self
}
// False positive
#[allow(clippy::missing_const_for_fn)]
pub fn language(mut self, language: String) -> Self {
self.language = Some(language);
self

View file

@ -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);
}
}
@ -160,7 +164,7 @@ fn handle_upload(
fragment = fragment.language(language);
}
url.set_fragment(Some(&fragment.build().expose_secret()));
url.set_fragment(Some(fragment.build().expose_secret()));
println!("{url}");

View file

@ -159,11 +159,10 @@ fn guess_mime_type(name_hint: Option<&str>, data: &[u8]) -> &'static str {
// support. As a result, we can probably just get the first one.
log!("[rs] Mime type inferred from extension.");
return mime_type;
} else {
}
log!("[rs] No mime type found for extension, falling back to introspection.");
}
}
tree_magic_mini::from_u8(&data)
tree_magic_mini::from_u8(data)
}
#[derive(Clone, Copy, Debug, PartialEq, Eq, PartialOrd, Ord)]