Compare commits

..

4 Commits

Author SHA1 Message Date
手瓜一十雪
da24ae7e1c fix: 空json5 2025-01-27 19:30:45 +08:00
Mlikiowa
8fc13f8a8f release: v4.4.13 2025-01-27 11:26:17 +00:00
手瓜一十雪
7e1fe31085 fix: http支持json5 2025-01-27 19:25:51 +08:00
Mlikiowa
c3cba8ba4e release: v4.4.12 2025-01-27 10:44:43 +00:00
4 changed files with 16 additions and 7 deletions

View File

@@ -4,7 +4,7 @@
"name": "NapCatQQ",
"slug": "NapCat.Framework",
"description": "高性能的 OneBot 11 协议实现",
"version": "4.4.11",
"version": "4.4.13",
"icon": "./logo.png",
"authors": [
{

View File

@@ -2,7 +2,7 @@
"name": "napcat",
"private": true,
"type": "module",
"version": "4.4.11",
"version": "4.4.13",
"scripts": {
"build:universal": "npm run build:webui && vite build --mode universal || exit 1",
"build:framework": "npm run build:webui && vite build --mode framework || exit 1",

View File

@@ -1 +1 @@
export const napCatVersion = '4.4.11';
export const napCatVersion = '4.4.13';

View File

@@ -8,6 +8,7 @@ import cors from 'cors';
import { HttpServerConfig } from '@/onebot/config/config';
import { NapCatOneBot11Adapter } from "@/onebot";
import { IOB11NetworkAdapter } from "@/onebot/network/adapter";
import json5 from 'json5';
export class OB11HttpServerAdapter extends IOB11NetworkAdapter<HttpServerConfig> {
private app: Express | undefined;
@@ -52,12 +53,20 @@ export class OB11HttpServerAdapter extends IOB11NetworkAdapter<HttpServerConfig>
this.app.use((req, res, next) => {
// 兼容处理没有带content-type的请求
req.headers['content-type'] = 'application/json';
const originalJson = express.json({ limit: '5000mb' });
originalJson(req, res, (err) => {
if (err) {
let rawData = '';
req.on('data', (chunk) => {
rawData += chunk;
});
req.on('end', () => {
try {
req.body = json5.parse(rawData || '{}');
next();
} catch (err) {
return res.status(400).send('Invalid JSON');
}
next();
});
req.on('error', (err) => {
return res.status(400).send('Invalid JSON');
});
});