fix: slicing larger indexes explodes

This commit is contained in:
əlemi 2023-12-23 03:24:45 +01:00
parent 7aee304b70
commit d6b5ff42be
Signed by: alemi
GPG key ID: A4895B84D311642C

View file

@ -47,8 +47,8 @@ async fn send_suggestion(payload: Insertion, state: SafeContext) -> impl IntoRes
let avatar = hasher.finalize(); let avatar = hasher.finalize();
let page = GuestBookPage { let page = GuestBookPage {
avatar: format!("{:x}", avatar), avatar: format!("{:x}", avatar),
author: payload.author.map(|x| x[..25].to_string()), // TODO don't hardcode char limits! author: payload.author.map(|x| x.chars().take(25).collect()), // TODO don't hardcode char limits!
contact: payload.contact.clone().map(|x| x[..50].to_string()), contact: payload.contact.clone().map(|x| x.chars().take(50).collect()),
body: payload.body, body: payload.body,
date: Utc::now(), date: Utc::now(),
url: match payload.contact { url: match payload.contact {