From a1bac4b30edb358b1f500bf67422ddbb51b21ff0 Mon Sep 17 00:00:00 2001 From: Rob Wagner Date: Mon, 23 Oct 2023 22:52:01 -0400 Subject: [PATCH] Remove unnecessary .to_string() call when creating a header from JSON data The original version would double quote values, resulting in serde_json inserting escape characters into the final string value, which prevented the header from being parsed by htmx properly. --- src/responders/serde.rs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/responders/serde.rs b/src/responders/serde.rs index d60eb8d..fd1eec1 100644 --- a/src/responders/serde.rs +++ b/src/responders/serde.rs @@ -193,8 +193,9 @@ pub(crate) fn events_to_header_value(events: Vec) -> Result>(); + .map(|e| (e.name, e.data.unwrap_or_default())) + .collect::>(); + serde_json::to_string(&header_value)? } else { // no event contains data, the event names can be put in the header