Special case front page so it never gets a non-empty slug

This commit is contained in:
Magnus Hoff 2017-09-21 10:23:30 +02:00
parent 338f8346aa
commit 01dafa7d37

View file

@ -27,6 +27,11 @@ pub enum SlugLookup {
} }
fn decide_slug(conn: &SqliteConnection, article_id: i32, prev_title: &str, title: &str, prev_slug: &str) -> Result<String, Error> { fn decide_slug(conn: &SqliteConnection, article_id: i32, prev_title: &str, title: &str, prev_slug: &str) -> Result<String, Error> {
if prev_slug == "" {
// Never give a non-empty slug to the front page
return Ok(String::new());
}
if title == prev_title { if title == prev_title {
return Ok(prev_slug.to_owned()); return Ok(prev_slug.to_owned());
} }