diff --git a/src/nex.rs b/src/nex.rs index d9589a7..263f51f 100644 --- a/src/nex.rs +++ b/src/nex.rs @@ -22,10 +22,14 @@ impl Nex { pattern: String, user_names: &Vec, ) -> Result { + use std::path::MAIN_SEPARATOR; + if filename.contains(MAIN_SEPARATOR) { + bail!("Filename pattern should not contain `{MAIN_SEPARATOR}` characters!") + } // init data export location let target = PathBuf::from_str(&target_dir)?.canonicalize()?; if !target.is_dir() { - bail!("Target location is not directory!"); + bail!("Target location is not directory!") } // init locations for each user let mut users = HashMap::with_capacity(user_names.len()); @@ -156,11 +160,7 @@ impl Nex { ); // save post file - p.push( - published - .format(self.filename.trim_matches(std::path::MAIN_SEPARATOR)) - .to_string(), - ); + p.push(published.format(&self.filename).to_string()); let f = p.to_string_lossy(); if fs::exists(&p)? { println!("\t\t\tpost file `{f}` update with new content.")