mirror of
https://github.com/LemmyNet/lemmy.git
synced 2024-11-30 00:01:25 +00:00
Empty post bodies (#2050)
* Cleaning optional post bodies. Fixes #2039
* Only trim once.
* Using .map() instead.
* Revert "Using .map() instead."
This reverts commit a2f4907209
.
This commit is contained in:
parent
f23fed70bc
commit
16271b0a4c
1 changed files with 10 additions and 1 deletions
|
@ -176,7 +176,16 @@ pub fn clean_url_params(mut url: Url) -> Url {
|
|||
}
|
||||
|
||||
pub fn clean_optional_text(text: &Option<String>) -> Option<String> {
|
||||
text.as_ref().map(|t| t.trim().to_string())
|
||||
if let Some(text) = text {
|
||||
let trimmed = text.trim();
|
||||
if trimmed.is_empty() {
|
||||
None
|
||||
} else {
|
||||
Some(trimmed.to_owned())
|
||||
}
|
||||
} else {
|
||||
None
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
|
|
Loading…
Reference in a new issue