From 01dafa7d372c7ff1ad5fc13aa90e5821ae98bc32 Mon Sep 17 00:00:00 2001 From: Magnus Hoff Date: Thu, 21 Sep 2017 10:23:30 +0200 Subject: [PATCH] Special case front page so it never gets a non-empty slug --- src/state.rs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/state.rs b/src/state.rs index 3551bff..ddcfaef 100644 --- a/src/state.rs +++ b/src/state.rs @@ -27,6 +27,11 @@ pub enum SlugLookup { } fn decide_slug(conn: &SqliteConnection, article_id: i32, prev_title: &str, title: &str, prev_slug: &str) -> Result { + if prev_slug == "" { + // Never give a non-empty slug to the front page + return Ok(String::new()); + } + if title == prev_title { return Ok(prev_slug.to_owned()); }