From d52ed81a29de39823a78b668d162851f880a6687 Mon Sep 17 00:00:00 2001 From: tempChanghong Date: Mon, 1 Dec 2025 15:06:52 +0800 Subject: [PATCH] =?UTF-8?q?Fix:=20=E5=85=81=E8=AE=B8=E4=BF=9D=E5=AD=98?= =?UTF-8?q?=E7=A9=BA=E6=95=B0=E7=BB=84=EF=BC=8C=E4=BF=AE=E5=A4=8D=E6=97=A0?= =?UTF-8?q?=E6=B3=95=E5=88=A0=E9=99=A4=E6=9C=80=E5=90=8E=E4=B8=80=E6=9D=A1?= =?UTF-8?q?=E9=80=9A=E7=9F=A5=E7=9A=84Bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .idea/.gitignore | 8 ++++++++ .idea/FixClassworksKV.iml | 12 ++++++++++++ .idea/modules.xml | 8 ++++++++ .idea/vcs.xml | 6 ++++++ routes/kv-token.js | 7 +++++-- 5 files changed, 39 insertions(+), 2 deletions(-) create mode 100644 .idea/.gitignore create mode 100644 .idea/FixClassworksKV.iml create mode 100644 .idea/modules.xml create mode 100644 .idea/vcs.xml diff --git a/.idea/.gitignore b/.idea/.gitignore new file mode 100644 index 0000000..35410ca --- /dev/null +++ b/.idea/.gitignore @@ -0,0 +1,8 @@ +# 默认忽略的文件 +/shelf/ +/workspace.xml +# 基于编辑器的 HTTP 客户端请求 +/httpRequests/ +# Datasource local storage ignored files +/dataSources/ +/dataSources.local.xml diff --git a/.idea/FixClassworksKV.iml b/.idea/FixClassworksKV.iml new file mode 100644 index 0000000..24643cc --- /dev/null +++ b/.idea/FixClassworksKV.iml @@ -0,0 +1,12 @@ + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml new file mode 100644 index 0000000..09fff6f --- /dev/null +++ b/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 0000000..35eb1dd --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/routes/kv-token.js b/routes/kv-token.js index 8090577..0c0af6e 100644 --- a/routes/kv-token.js +++ b/routes/kv-token.js @@ -356,7 +356,10 @@ router.post( const {key} = req.params; const value = req.body; - if (!value || Object.keys(value).length === 0) { + // 【修改点】允许空数组通过校验,但继续拦截真正的空对象 {} + // 如果 value 是空数组 [],Object.keys 为 0,但 !Array.isArray 为 false,条件为 false -> 通过 + // 如果 value 是空对象 {},Object.keys 为 0,且 !Array.isArray 为 true,条件为 true -> 拦截 + if (!value || (Object.keys(value).length === 0 && !Array.isArray(value))) { return next(errors.createError(400, "请提供有效的JSON值")); } @@ -429,4 +432,4 @@ router.delete( }) ); -export default router; \ No newline at end of file +export default router;v \ No newline at end of file