Skip to content

Commit

Permalink
Merge pull request #9 from oscar-project/dev-edit-blocklist
Browse files Browse the repository at this point in the history
add mut getter on domains
  • Loading branch information
Uinelj authored Nov 9, 2023
2 parents fc6d7e2 + 965ddc5 commit d0ce67e
Showing 1 changed file with 24 additions and 2 deletions.
26 changes: 24 additions & 2 deletions src/blocklist_multi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -269,6 +269,10 @@ impl Blocklist {
Some(detections)
}
}

pub fn domains_mut(&mut self) -> &mut HashMap<String, Vec<String>> {
&mut self.domains
}
}

#[cfg(test)]
Expand All @@ -278,8 +282,6 @@ mod tests {
path::Path,
};



use super::Blocklist;

// long test
Expand All @@ -293,6 +295,26 @@ mod tests {
);
}

#[test]
fn test_edit() {
let domains = vec![("blogspot.com".to_string(), vec!["blog".to_string()])]
.into_iter()
.collect();

let mut b = Blocklist::new(domains, HashMap::new());
assert_eq!(
b.detect("https://not_here.com/foo"),
None // Some(vec![&"blog".to_string()].into_iter().collect())
);

b.domains_mut()
.insert("not_here.com".to_string(), vec!["blog".to_string()]);
assert_eq!(
b.detect("https://not_here.com/foo"),
Some(vec![&"blog".to_string()].into_iter().collect())
);
}

#[test]
fn subdomains() {
let domains = vec![
Expand Down

0 comments on commit d0ce67e

Please sign in to comment.