1
0
mirror of https://gitlab.com/comunic/comunicapiv3 synced 2025-06-21 00:45:18 +00:00

Can create YouTube posts

This commit is contained in:
2020-07-08 13:05:06 +02:00
parent 8753f77227
commit 11051b28a0
3 changed files with 41 additions and 3 deletions

View File

@ -50,4 +50,25 @@ pub fn check_url(url: &str) -> bool {
/// ```
pub fn check_string_before_insert(s: &str) -> bool {
s.trim().len() > 3
}
/// Check the validity of a YouTube ID
///
/// ```
/// use comunic_server::utils::string_utils::check_youtube_id;
///
/// assert_eq!(check_youtube_id("/ab/"), false);
/// assert_eq!(check_youtube_id("abxZ96C"), true);
/// assert_eq!(check_youtube_id("a6C"), false);
/// ```
pub fn check_youtube_id(id: &str) -> bool {
id.len() >= 5
&& !id.contains("/")
&& !id.contains("\\")
&& !id.contains("@")
&& !id.contains("&")
&& !id.contains("?")
&& !id.contains(".")
&& !id.contains("'")
&& !id.contains("\"")
}