Skip to content

Commit

Permalink
fixed printing same text multiple times
Browse files Browse the repository at this point in the history
  • Loading branch information
QpxDesign committed Jul 13, 2024
1 parent 515f25d commit 222d3fb
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 3 deletions.
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

[package]
name = "webgrep"
version = "0.3.0"
version = "0.3.1"
edition = "2021"
license = "MIT"
description = "grep the web: a full-browser-spec search-focused ultra-simple way to read the web without having to leave the terminal"
Expand Down
4 changes: 3 additions & 1 deletion src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,10 @@ async fn main() {
re = Regex::new(&args.search.unwrap()).unwrap();
}
for (link, texts) in text_elements.into_iter() {
let mut printed_texts: HashMap<String, bool> = HashMap::new();
for text in texts {
if re.is_match(&text) {
if re.is_match(&text) && !printed_texts.contains_key(&text) {
printed_texts.insert(text.to_string(), true);
if num_urls > 1 {
print!("{}", link.blue());
print!("{}", ":".green());
Expand Down

0 comments on commit 222d3fb

Please sign in to comment.