diff --git a/routes/web.php b/routes/web.php index c296db3..52489c0 100644 --- a/routes/web.php +++ b/routes/web.php @@ -52,6 +52,13 @@ use thiagoalessio\TesseractOCR\TesseractOCR; ->config('tessedit_char_whitelist', '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz') ->run(); + $text = trim($text); // remove whitespace + + if (empty($text)) { + // No text found + return response()->json(['success' => true, 'text' => 'Text not found']); + } + //return response()->json(['success' => true, 'text' => $text]); $lines = preg_split('/\r\n|\r|\n/', $text); $serials = array_filter(array_map('trim', $lines), fn($line) => preg_match('/^[A-Za-z0-9]+$/', $line));