fix: tolerar URL de OCR con /extract incluido por error

Si en el panel se pega la URL completa (https://host/extract) en vez del
dominio base, el servicio duplicaba la ruta (.../extract/extract) y daba
404. normalizarUrl() ahora le quita el /extract final si ya viene, tanto
en el flujo real como en el boton "Probar conexion".

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
Lizandro
2026-08-11 00:34:27 +00:00
co-authored by Claude Sonnet 5
parent 7afd22d581
commit 978c7c1492
2 changed files with 9 additions and 2 deletions
@@ -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) {
+8 -1
View File
@@ -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 !== '';