From 5e1fcff979e26e052e35321106c7d355458901ae Mon Sep 17 00:00:00 2001 From: Daniel Szabo Date: Mon, 7 Nov 2022 20:25:42 +0200 Subject: [PATCH] Fixed a bug that caused url pastas to become plain text pastas --- src/endpoints/create.rs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/endpoints/create.rs b/src/endpoints/create.rs index be8250d..715007e 100644 --- a/src/endpoints/create.rs +++ b/src/endpoints/create.rs @@ -121,15 +121,16 @@ pub async fn create( let mut content = String::from(""); while let Some(chunk) = field.try_next().await? { content.push_str(std::str::from_utf8(&chunk).unwrap().to_string().as_str()); + } + if content.len() > 0 { + new_pasta.content = content; + new_pasta.pasta_type = if is_valid_url(new_pasta.content.as_str()) { String::from("url") } else { String::from("text") }; } - if content.len() > 0 { - new_pasta.content = content; - } continue; } "syntax-highlight" => {