From ca6b1634690f27f0edc5d4285d8d4c738fb4ca25 Mon Sep 17 00:00:00 2001 From: Alexander Medvedev Date: Tue, 7 Apr 2026 16:35:34 +0200 Subject: [PATCH] chore: add review lengh limit --- src/pages/PluginDetail.tsx | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/pages/PluginDetail.tsx b/src/pages/PluginDetail.tsx index eb2272d..bf86cd6 100644 --- a/src/pages/PluginDetail.tsx +++ b/src/pages/PluginDetail.tsx @@ -17,6 +17,8 @@ const REPORT_REASONS = [ 'Other', ]; +const MAX_REVIEW_LENGTH = 2000; + const StarRating = ({ rating, max = 5, onRate }: { rating: number; max?: number; onRate?: (n: number) => void }) => (
{[...Array(max)].map((_, i) => ( @@ -219,7 +221,10 @@ const PluginDetail = () => { const submitReview = async (e: React.FormEvent) => { e.preventDefault(); - if (!reviewForm.comment.trim()) return; + const comment = reviewForm.comment.trim(); + if (!comment || comment.length > MAX_REVIEW_LENGTH) { + return; + } await api.post(`/plugins/${id}/reviews`, reviewForm); fetchPlugin(); setReviewForm({ rating: 5, comment: '' }); @@ -454,6 +459,7 @@ const PluginDetail = () => {