make it show articles whose beginning matches if none else are found
This commit is contained in:
parent
dbafc63e4b
commit
3553f2171b
1 changed files with 3 additions and 3 deletions
|
|
@ -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}"),
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue