From 7957776f53a4af82546583006167a412573d8d67 Mon Sep 17 00:00:00 2001 From: poignatov Date: Tue, 10 Mar 2026 15:41:34 +0300 Subject: [PATCH] =?UTF-8?q?6.6.0:=20=D0=98=D0=B7=D0=B2=D0=BB=D0=B5=D1=87?= =?UTF-8?q?=D0=B5=D0=BD=D0=B8=D0=B5=20=D1=81=D1=81=D1=8B=D0=BB=D0=BA=D0=B8?= =?UTF-8?q?=20=D0=B8=D0=B7=20=D1=82=D0=B5=D0=BA=D1=81=D1=82=D0=B0=20=D0=B2?= =?UTF-8?q?=20=D0=B6=D0=B5=D0=BB=D0=B0=D0=BD=D0=B8=D0=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- VERSION | 2 +- play-life-web/package.json | 2 +- play-life-web/src/components/WishlistForm.jsx | 28 ++++++++++++++----- 3 files changed, 23 insertions(+), 9 deletions(-) diff --git a/VERSION b/VERSION index f22d756..826f5ce 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -6.5.0 +6.6.0 diff --git a/play-life-web/package.json b/play-life-web/package.json index 96ea8ab..cc34ca5 100644 --- a/play-life-web/package.json +++ b/play-life-web/package.json @@ -1,6 +1,6 @@ { "name": "play-life-web", - "version": "6.5.0", + "version": "6.6.0", "type": "module", "scripts": { "dev": "vite", diff --git a/play-life-web/src/components/WishlistForm.jsx b/play-life-web/src/components/WishlistForm.jsx index 3533177..834859a 100644 --- a/play-life-web/src/components/WishlistForm.jsx +++ b/play-life-web/src/components/WishlistForm.jsx @@ -4,6 +4,13 @@ import { useAuth } from './auth/AuthContext' import Toast from './Toast' import './WishlistForm.css' +// Извлекает первый URL из текста +function extractUrl(text) { + if (!text) return '' + const match = text.match(/https?:\/\/[^\s<>"'`,;!)\]]+/i) + return match ? match[0] : text +} + const API_URL = '/api/wishlist' const TASKS_API_URL = '/api/tasks' const PROJECTS_API_URL = '/projects' @@ -359,15 +366,18 @@ function WishlistForm({ onNavigate, wishlistId, editConditionIndex, newTaskId: n setToastMessage({ text: 'Введите ссылку', type: 'error' }) return } - + + const extracted = extractUrl(link) + setLink(extracted) + // Проверяем валидность URL try { - new URL(link) + new URL(extracted) } catch { setToastMessage({ text: 'Некорректная ссылка', type: 'error' }) return } - + setFetchingMetadata(true) try { const response = await authFetch(`${API_URL}/metadata`, { @@ -375,7 +385,7 @@ function WishlistForm({ onNavigate, wishlistId, editConditionIndex, newTaskId: n headers: { 'Content-Type': 'application/json', }, - body: JSON.stringify({ url: link.trim() }), + body: JSON.stringify({ url: extracted.trim() }), }) if (response.ok) { @@ -477,7 +487,9 @@ function WishlistForm({ onNavigate, wishlistId, editConditionIndex, newTaskId: n // Загрузка картинки по ссылке с последующим кропом const loadImageFromUrl = async () => { - const url = imageUrlInput?.trim() + const extracted = extractUrl(imageUrlInput) + setImageUrlInput(extracted) + const url = extracted?.trim() if (!url) { setToastMessage({ text: 'Введите ссылку на картинку', type: 'error' }) return @@ -800,9 +812,10 @@ function WishlistForm({ onNavigate, wishlistId, editConditionIndex, newTaskId: n
setLink(e.target.value)} + onBlur={() => setLink(extractUrl(link))} placeholder="https://..." className="form-input" disabled={fetchingMetadata} @@ -907,9 +920,10 @@ function WishlistForm({ onNavigate, wishlistId, editConditionIndex, newTaskId: n
Ссылка: setImageUrlInput(e.target.value)} + onBlur={() => setImageUrlInput(extractUrl(imageUrlInput))} placeholder="https://..." className="form-input image-url-input" disabled={loadingImageFromUrl}