Browse Source

make domain protocol validation work with multi-domains

pull/3870/merge^2
BlockListed 2 years ago
parent
commit
e313745f7c
No known key found for this signature in database GPG Key ID: 2D204777C477B588
  1. 6
      src/config.rs

6
src/config.rs

@ -733,12 +733,14 @@ fn validate_config(cfg: &ConfigItems) -> Result<(), Error> {
} }
} }
let dom = cfg.domain.to_lowercase(); let domains = cfg.domain_change_back.split(',').map(|d| d.to_string().to_lowercase());
for dom in domains {
if !dom.starts_with("http://") && !dom.starts_with("https://") { if !dom.starts_with("http://") && !dom.starts_with("https://") {
err!( err!(
"DOMAIN variable needs to contain the protocol (http, https). Use 'http[s]://bw.example.com' instead of 'bw.example.com'" "DOMAIN variable needs to contain the protocol (http, https). Use 'http[s]://bw.example.com' instead of 'bw.example.com'"
); );
} }
}
let whitelist = &cfg.signups_domains_whitelist; let whitelist = &cfg.signups_domains_whitelist;
if !whitelist.is_empty() && whitelist.split(',').any(|d| d.trim().is_empty()) { if !whitelist.is_empty() && whitelist.split(',').any(|d| d.trim().is_empty()) {
@ -1314,6 +1316,8 @@ impl Config {
}).get(host).map(|h| h.clone()) }).get(host).map(|h| h.clone())
} }
// Yes this is a base_url
// But the configuration precedent says, that we call this a domain.
pub fn main_domain(&self) -> String { pub fn main_domain(&self) -> String {
self.domain_change_back().split(',').nth(0).expect("Missing domain").to_string() self.domain_change_back().split(',').nth(0).expect("Missing domain").to_string()
} }

Loading…
Cancel
Save