diff --git a/api_tests/src/post.spec.ts b/api_tests/src/post.spec.ts index 72029157d..780160c39 100644 --- a/api_tests/src/post.spec.ts +++ b/api_tests/src/post.spec.ts @@ -76,7 +76,12 @@ test("Create a post", async () => { throw "Missing beta community"; } - let postRes = await createPost(alpha, betaCommunity.community.id); + let postRes = await createPost( + alpha, + betaCommunity.community.id, + "https://example.com/", + "აშშ ითხოვს ირანს დაუყოვნებლივ გაანთავისუფლოს დაკავებული ნავთობის ტანკერი", + ); expect(postRes.post_view.post).toBeDefined(); expect(postRes.post_view.community.local).toBe(false); expect(postRes.post_view.creator.local).toBe(true); diff --git a/api_tests/src/shared.ts b/api_tests/src/shared.ts index 9a2d45075..13b07c9b7 100644 --- a/api_tests/src/shared.ts +++ b/api_tests/src/shared.ts @@ -202,10 +202,10 @@ export async function setupLogins() { export async function createPost( api: LemmyHttp, community_id: number, - // use example.com for consistent title and embed description url: string = "https://example.com/", + // use example.com for consistent title and embed description + name: string = randomString(5), ): Promise { - let name = randomString(5); let body = randomString(10); let form: CreatePost = { name, diff --git a/crates/utils/src/utils/validation.rs b/crates/utils/src/utils/validation.rs index bb4592fc5..0777ac6f8 100644 --- a/crates/utils/src/utils/validation.rs +++ b/crates/utils/src/utils/validation.rs @@ -147,7 +147,7 @@ pub fn is_valid_matrix_id(matrix_id: &str) -> LemmyResult<()> { } pub fn is_valid_post_title(title: &str) -> LemmyResult<()> { - let length = title.trim().len(); + let length = title.trim().chars().count(); let check = (3..=200).contains(&length) && !has_newline(title); if !check { Err(LemmyErrorType::InvalidPostTitle.into()) @@ -380,6 +380,10 @@ mod tests { #[test] fn test_valid_post_title() { assert!(is_valid_post_title("Post Title").is_ok()); + assert!(is_valid_post_title( + "აშშ ითხოვს ირანს დაუყოვნებლივ გაანთავისუფლოს დაკავებული ნავთობის ტანკერი" + ) + .is_ok()); assert!(is_valid_post_title(" POST TITLE 😃😃😃😃😃").is_ok()); assert!(is_valid_post_title("\n \n \n \n ").is_err()); // tabs/spaces/newlines }