Skip to content

Commit

Permalink
Handle space and underscore as if they were the same char
Browse files Browse the repository at this point in the history
This is what MediaWiki does, and the change should make socksfinder a bit more
intuitive for users.

Thanks to (:Julien:) for the idea.
  • Loading branch information
Arkanosis committed Mar 5, 2023
1 parent 8fd7231 commit 4afae57
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 4 deletions.
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Copyright (C) 2020-2022 Jérémie Roquet <[email protected]>
Copyright (C) 2020-2023 Jérémie Roquet <[email protected]>

Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted, provided that the above
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -292,5 +292,5 @@ Please report bugs and feature requests on [GitHub issues](https://github.com/Ar

## License

socksfinder is copyright (C) 2020-2022 Jérémie Roquet <[email protected]>
socksfinder is copyright (C) 2020-2023 Jérémie Roquet <[email protected]>
and licensed under the ISC license.
5 changes: 3 additions & 2 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,8 @@ pub fn build(reader: &mut dyn BufRead, writer: &mut dyn Write) -> Result<(), ()>
Tag::UserName => {
match escaped_event {
Ok(ref buffer) => {
let page_offsets = user_page_offsets.entry(buffer.as_bytes().to_vec()).or_insert(Vec::new());
let user = buffer.replace("_", " ");
let page_offsets = user_page_offsets.entry(user.as_bytes().to_vec()).or_insert(Vec::new());
match page_offsets.last() {
None => page_offsets.push(current_offset),
Some(last_offset) => {
Expand Down Expand Up @@ -234,7 +235,7 @@ pub fn query(index: &mut dyn Index, writer: &mut dyn Write, users: &Vec<String>,
let users: &Vec<String> = {
let mut unique_users = HashSet::with_capacity(users.len());
for user in users {
unique_users.insert(user.trim().to_string().clone());
unique_users.insert(user.replace("_", " ").trim().to_string().clone());
}
&unique_users.into_iter().collect()
};
Expand Down

0 comments on commit 4afae57

Please sign in to comment.