make it show articles whose beginning matches if none else are found

This commit is contained in:
Tove 2025-11-26 19:21:40 +00:00
parent dbafc63e4b
commit 3553f2171b

View file

@ -76,7 +76,7 @@ impl SSR {
.map(|x| with_status(x, StatusCode::OK))
}
pub async fn snippet(&self, snippet: &str) -> Option<WithStatus<Html<String>>> {
pub async fn snippet(&self, mut snippet: &str) -> Option<WithStatus<Html<String>>> {
if snippet.contains("..") {
return None; // evil
}
@ -87,8 +87,8 @@ impl SSR {
read_string(format!("snippet/{snippet}.html")),
)
.await;
if htmlout.is_none() {
let snippet = &snippet[0..snippet.len() - 1];
while htmlout.is_none() && snippet.len() > 0 {
snippet = &snippet[0..snippet.len() - 1];
htmlout = self
.render(
format!("snippet:{snippet}"),