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:
co-authored by
Claude Sonnet 5
parent
7afd22d581
commit
978c7c1492
@@ -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) {
|
||||
|
||||
@@ -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 !== '';
|
||||
|
||||
Reference in New Issue
Block a user