Add duplicate domain check, closes #5
All checks were successful
Run Tests on Code / run-tests (push) Successful in 13s
All checks were successful
Run Tests on Code / run-tests (push) Successful in 13s
This commit is contained in:
parent
a028d4245b
commit
76a567d1bf
1 changed files with 28 additions and 1 deletions
27
src/main.rs
27
src/main.rs
|
@ -146,6 +146,7 @@ impl Config {
|
|||
let msg = format!("Using {}", path);
|
||||
directories.push(system_path.to_path_buf());
|
||||
info!(msg);
|
||||
Self::check_for_duplicate_domains(&user_config.domain_configs);
|
||||
Ok((Config {
|
||||
user: user_config,
|
||||
system: data,
|
||||
|
@ -224,6 +225,32 @@ impl Config {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn check_for_duplicate_domains(domain_configs: &[DomainLinkConfig]) {
|
||||
let mut checked_domains: Vec<String> = vec![];
|
||||
for (cfg_idx, config) in domain_configs.iter().enumerate() {
|
||||
for (idx, domain) in config.domains.iter().enumerate() {
|
||||
if !checked_domains.contains(domain) {
|
||||
if config.domains[idx+1..].contains(domain) {
|
||||
// Error
|
||||
let msg = format!("Duplicate Domain use detected for '{domain}");
|
||||
warn!(msg);
|
||||
checked_domains.push(domain.clone());
|
||||
}
|
||||
else {
|
||||
for d in domain_configs[cfg_idx+1..].iter() {
|
||||
if d.domains.contains(domain) {
|
||||
let msg = format!("Duplicate Domain use detected for '{domain}");
|
||||
warn!(msg);
|
||||
checked_domains.push(domain.clone());
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[actix_web::main]
|
||||
|
|
Loading…
Reference in a new issue