Skip to content

Commit

Permalink
properly fix the is_nsfw check this time
Browse files Browse the repository at this point in the history
  • Loading branch information
arqunis committed Jul 2, 2018
1 parent dd1e97a commit ccd2506
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/utils/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ pub fn vecmap_to_json_map<K: PartialEq + ToString>(map: VecMap<K, Value>) -> Map
/// assert!(!utils::is_nsfw("nsfwstuff"));
/// ```
pub fn is_nsfw(name: &str) -> bool {
name == "nsfw" || name.starts_with("nsfw-")
name == "nsfw" || name.chars().count() > 5 && name.starts_with("nsfw-")
}

/// Retrieves the "code" part of an invite out of a URL.
Expand Down
2 changes: 1 addition & 1 deletion tests/test_channels.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ mod utils {

channel.kind = ChannelType::Text;
channel.name = "nsfw-".to_string();
assert!(channel.is_nsfw());
assert!(!channel.is_nsfw());

channel.name = "nsfw".to_string();
assert!(channel.is_nsfw());
Expand Down
5 changes: 3 additions & 2 deletions tests/test_utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ 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"));
}
assert!(is_nsfw("nsfw-général"));
}

0 comments on commit ccd2506

Please sign in to comment.