diff --git a/app/Http/Livewire/Chat/ShowConfiguracionChat.php b/app/Http/Livewire/Chat/ShowConfiguracionChat.php index cd44041..077534c 100755 --- a/app/Http/Livewire/Chat/ShowConfiguracionChat.php +++ b/app/Http/Livewire/Chat/ShowConfiguracionChat.php @@ -182,7 +182,7 @@ class ShowConfiguracionChat extends Component public function probarOcr(): void { - $url = rtrim(trim($this->ocr_url ?: ChatConfig::get('ocr_url')), '/'); + $url = \App\Services\OcrExtractionService::normalizarUrl($this->ocr_url ?: ChatConfig::get('ocr_url')); $token = trim($this->ocr_token ?: ChatConfig::get('ocr_token')); if (! $url) { diff --git a/app/Services/OcrExtractionService.php b/app/Services/OcrExtractionService.php index ff515f6..22ff500 100644 --- a/app/Services/OcrExtractionService.php +++ b/app/Services/OcrExtractionService.php @@ -13,10 +13,17 @@ class OcrExtractionService public function __construct() { - $this->url = rtrim(ChatConfig::get('ocr_url', ''), '/'); + $this->url = self::normalizarUrl(ChatConfig::get('ocr_url', '')); $this->token = ChatConfig::get('ocr_token', ''); } + /** Acepta tanto "https://host" como "https://host/extract" (error comun de configuracion). */ + public static function normalizarUrl(string $url): string + { + $url = rtrim(trim($url), '/'); + return preg_replace('#/extract$#', '', $url); + } + public function habilitado(): bool { return ChatConfig::get('ocr_habilitado', '0') === '1' && $this->url !== '';