Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PTV-1911: Fix user search bugs re underscores + mongo errors #439

Merged
merged 1 commit into from
Jun 4, 2024

Conversation

MrCreosote
Copy link
Member

@MrCreosote MrCreosote commented Jun 3, 2024

  • Fixed a bug where if a user name contained an underscore and the search term included the underscore followed by at least one letter the search wouldn't match
  • Fixed a bug where if the search terms were all illegal characters such that the search list was empty for a requested search a mongo error would be thrown

Fixes #435

* Fixed a bug where if a user name contained an underscore and
the search term included the underscore followed by at least one
letter the search wouldn't match
* Fixed a bug where if the search terms were all illegal characters
such that the search list was empty for a requested search a
mongo error would be thrown
@MrCreosote MrCreosote requested a review from ialarmedalien June 3, 2024 21:28
Copy link

codecov bot commented Jun 3, 2024

Codecov Report

Attention: Patch coverage is 96.36364% with 2 lines in your changes missing coverage. Please review.

Project coverage is 93.37%. Comparing base (b93fdd8) to head (5527329).

Additional details and impacted files
@@              Coverage Diff              @@
##             develop     #439      +/-   ##
=============================================
- Coverage      93.37%   93.37%   -0.01%     
- Complexity      2144     2151       +7     
=============================================
  Files            126      126              
  Lines           7531     7558      +27     
  Branches        1178     1184       +6     
=============================================
+ Hits            7032     7057      +25     
- Misses           456      458       +2     
  Partials          43       43              

@@ -35,8 +39,8 @@ public class UserName extends Name {
}
}

private static final String INVALID_CHARS_REGEX = "[^a-z\\d_]+";
private final static Pattern INVALID_CHARS = Pattern.compile(INVALID_CHARS_REGEX);
private static final Pattern FORCE_ALPHA_FIRST_CHAR = Pattern.compile("^[^a-z]+");

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I hope 2pac never made a KBase account!

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure how deep KBase has penetrated into the gangsta rap community

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Something to check with KBase outreach about.

private static final String INVALID_CHARS_REGEX = "[^a-z\\d_]+";
private final static Pattern INVALID_CHARS = Pattern.compile(INVALID_CHARS_REGEX);
private static final Pattern FORCE_ALPHA_FIRST_CHAR = Pattern.compile("^[^a-z]+");
private final static Pattern INVALID_CHARS = Pattern.compile("[^a-z\\d_]+");

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you use \\W+, since \w is equivalent to [a-z0-9_] in most regex implementations?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That would work, but my personal preference is to use the more explicit form where you don't have to look up what W means

@MrCreosote MrCreosote merged commit f4f368c into develop Jun 4, 2024
9 checks passed
@MrCreosote MrCreosote deleted the dev-user_search branch December 5, 2024 23:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

User names with underscores don't show up in search if the search term contains an underscore
2 participants