diff --git a/.gitignore b/.gitignore index 932b8d8..bb1ca12 100644 --- a/.gitignore +++ b/.gitignore @@ -5,5 +5,4 @@ /ptth_relay.toml /ptth_build_L6KLMVS6/ /target -/test diff --git a/src/server/file_server.rs b/src/server/file_server.rs index c8d384c..7d9084b 100644 --- a/src/server/file_server.rs +++ b/src/server/file_server.rs @@ -235,7 +235,7 @@ async fn serve_root ( fn serve_html (s: String) -> Response { let mut resp = Response::default (); resp - .header ("content-type".to_string (), "text/html".to_string ().into_bytes ()) + .header ("content-type".to_string (), "text/html; charset=UTF-8".to_string ().into_bytes ()) .body_bytes (s.into_bytes ()) ; resp @@ -394,10 +394,13 @@ fn render_markdown (bytes: &[u8]) -> Result { let parser = Parser::new_ext (markdown_input, options); // Write to String buffer. - let mut html_output = String::new (); - html::push_html (&mut html_output, parser); + let mut out = String::new (); - Ok (html_output) + out.push_str (""); + html::push_html (&mut out, parser); + out.push_str (""); + + Ok (out) } // Sort of an internal API endpoint to make testing work better. @@ -809,13 +812,12 @@ mod tests { range_requested: false, file: AlwaysEqual::testing_blank (), })), - ("/files/test.md", ServeFile (ServeFileParams { + ("/files/test/test.md", ServeFile (ServeFileParams { send_body: true, - range: 0..117, + range: 0..144, range_requested: false, file: AlwaysEqual::testing_blank (), })), - ("/files/test.md?as_markdown", MarkdownPreview ("

Markdown test

\n

This is a test file for the Markdown previewing feature.

\n

Don\'t change it, it will break the tests.

\n".into ())), ("/ ", InvalidUri), ].into_iter () { let resp = internal_serve_all ( diff --git a/test/face.png b/test/face.png new file mode 100644 index 0000000..18668bb Binary files /dev/null and b/test/face.png differ diff --git a/test.md b/test/test.md similarity index 81% rename from test.md rename to test/test.md index 120b141..119ee02 100644 --- a/test.md +++ b/test/test.md @@ -3,3 +3,5 @@ This is a test file for the Markdown previewing feature. Don't change it, it will break the tests. + +![A silly face](face.png) diff --git a/todo.md b/todo.md index c28e579..b3d977b 100644 --- a/todo.md +++ b/todo.md @@ -1,4 +1,4 @@ -- "Preview as" feature for Markdown / pretty-printed logs +- "Preview as" feature for Markdown (It's not threaded through the relay yet) - Make a debug client to replicate the issue Firefox is having with turtling - Add Prometheus metrics - Not working great behind reverse proxies