From c86ca3467f57f1a1a03ba344177dc07fea85dd3e Mon Sep 17 00:00:00 2001 From: Aravinth Manivannan Date: Wed, 9 Nov 2022 14:45:37 +0530 Subject: [PATCH] feat: website FS path construction utility --- src/utils.rs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/utils.rs b/src/utils.rs index e290a7f..add0136 100644 --- a/src/utils.rs +++ b/src/utils.rs @@ -14,6 +14,9 @@ * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see . */ +use crate::Settings; +use std::path::{Path, PathBuf}; + /// Get random string of specific length pub(crate) fn get_random(len: usize) -> String { use rand::{distributions::Alphanumeric, rngs::ThreadRng, thread_rng, Rng}; @@ -27,3 +30,7 @@ pub(crate) fn get_random(len: usize) -> String { .take(len) .collect::() } + +pub(crate) fn get_website_path(s: &Settings, hostname: &str) -> PathBuf { + Path::new(&s.page.base_path).join(hostname) +}