From 2592598ce36e938c0c615fb505a58ab755ff1a3b Mon Sep 17 00:00:00 2001 From: Anatoly Prohacky Date: Sun, 23 Apr 2023 19:24:28 +1000 Subject: [PATCH] correct if json --- pub/index.html | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/pub/index.html b/pub/index.html index f0e7fe0..e7e47fd 100644 --- a/pub/index.html +++ b/pub/index.html @@ -51,10 +51,9 @@ let formData = new FormData(); formData.append("file", file); let fileDown = file.name.replace(/\.[^.]+$/, "") - let fileRes = file.name.split('').reverse().join('').split('.')[0].split('').reverse().join(''); - - if (fileRes != "json") { - alert(`Format file not json`); + + if (file.type != "application/json") { + alert(`Формат файла должен быть ".json"`); return } @@ -64,7 +63,7 @@ }) .then(response => { if (!response.ok) { - throw new Error(`HTTP ${response.status} - ${response.body}`); + throw new Error(`HTTP ${response.status} - Конвертирование не удалось. Неизвестный формат данных.`); } return response.blob(); })