Skip to content

Commit

Permalink
Fix 'nsfw-' case in utils::is_nsfw
Browse files Browse the repository at this point in the history
In the utils::is_nsfw function, an input of 'nsfw-' shouldn't return true.
Discord's (previous) NSFW detection classified 'nsfw' and anything starting with
'nsfw-' - but not including - as NSFW.
  • Loading branch information
Zeyla Hellyer committed Jul 2, 2018
1 parent 0067c33 commit bd4aa0a
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/utils/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ pub fn is_nsfw(name: &str) -> bool {

if char_count == 4 {
name == "nsfw"
} else if char_count > 4 {
} else if char_count > 5 {
name.starts_with("nsfw-")
} else {
false
Expand Down
2 changes: 1 addition & 1 deletion tests/test_utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,6 @@ fn test_is_nsfw() {
assert!(!is_nsfw("general"));
assert!(is_nsfw("nsfw"));
assert!(is_nsfw("nsfw-test"));
assert!(is_nsfw("nsfw-"));
assert!(!is_nsfw("nsfw-"));
assert!(!is_nsfw("général"));
}

0 comments on commit bd4aa0a

Please sign in to comment.