diff --git a/src/config.rs b/src/config.rs index d1e909e..bd107de 100644 --- a/src/config.rs +++ b/src/config.rs @@ -146,14 +146,11 @@ impl ConfigFile { } fn web_base(&self) -> String { - let mut base = self.web.base.clone(); - if !base.starts_with('/') { - base.insert(0, '/'); - } - if !base.ends_with('/') { - base.push('/'); - } - base + self.web + .base + .strip_suffix('/') + .unwrap_or(&self.web.base) + .to_string() } fn web_worker_token(&self) -> String { @@ -210,14 +207,21 @@ impl ConfigFile { // TODO Url functions #[derive(Clone)] pub struct WorkerServerConfig { - /// Never ends with a `/`. + /// Always ends without a `/`. + /// + /// This means that you can prefix the url onto an absolute path and get a + /// correct url. pub url: String, pub token: String, } #[derive(Clone)] pub struct Config { - /// Always starts and ends with a `/`. + /// Always ends without a `/` (prioritizing the latter). + /// + /// This means that you can prefix the base onto an absolute path and get + /// another absolute path. You could also use an url here if you have a + /// weird reason to do so. pub web_base: String, pub web_address: SocketAddr, pub web_worker_token: String, diff --git a/src/server/web/link.rs b/src/server/web/link.rs index d9d1f05..c63bbce 100644 --- a/src/server/web/link.rs +++ b/src/server/web/link.rs @@ -9,7 +9,7 @@ use super::Base; ext = "html", source = "\ {% import \"util.html\" as util %} - {{ short }} @@ -38,7 +38,7 @@ impl CommitLink { #[template( ext = "html", source = "\ - + Run of {{ short }} " @@ -62,7 +62,7 @@ impl RunLink { #[template( ext = "html", source = "\ - + {{ name }} " diff --git a/templates/base.html b/templates/base.html index 5bf99cb..fd84699 100644 --- a/templates/base.html +++ b/templates/base.html @@ -5,17 +5,17 @@