fix: 修复新版 path-to-regexp 不兼容 '*' 通配符导致启动崩溃

新版 express/router 依赖的 path-to-regexp 不再接受裸 '*' 路径语法,
改为命名通配参数 :relPath(.*),并同步把 req.params[0] 改为
req.params.relPath。涉及 7 条 /media/* 静态路由:
- /media/audio/general/*
- /media/audio/beep/*
- /media/audio/music/*
- /media/audio/voice/*
- /media/audio/line/*
- /media/audio/station/*
- /media/temp/*

客户端版本号 bump v1.0.100 -> v1.0.101
This commit is contained in:
2026-08-17 15:38:41 +08:00
parent c9d8994942
commit fc66e43379
2 changed files with 15 additions and 15 deletions
+14 -14
View File
@@ -148,44 +148,44 @@ function safeRelativeToBase(baseDir, relativePath) {
return full;
}
app.get('/media/audio/general/*', (req, res) => {
const rel = req.params[0] || '';
app.get('/media/audio/general/:relPath(.*)', (req, res) => {
const rel = req.params.relPath || '';
const candidates = getBeepAudioDirs().map(dir => safeRelativeToBase(dir, rel)).filter(Boolean);
sendBinaryFileFromCandidates(res, candidates);
});
app.get('/media/audio/beep/*', (req, res) => {
const rel = req.params[0] || '';
app.get('/media/audio/beep/:relPath(.*)', (req, res) => {
const rel = req.params.relPath || '';
const candidates = getBeepAudioDirs().map(dir => safeRelativeToBase(dir, rel)).filter(Boolean);
sendBinaryFileFromCandidates(res, candidates);
});
app.get('/media/audio/music/*', (req, res) => {
const rel = req.params[0] || '';
app.get('/media/audio/music/:relPath(.*)', (req, res) => {
const rel = req.params.relPath || '';
const full = safeRelativeToBase(audioMusicDir, rel);
if (!full) return res.status(404).end();
sendBinaryFile(res, full);
});
app.get('/media/audio/voice/*', (req, res) => {
const rel = req.params[0] || '';
app.get('/media/audio/voice/:relPath(.*)', (req, res) => {
const rel = req.params.relPath || '';
const full = safeRelativeToBase(audioVoiceDir, rel);
if (!full) return res.status(404).end();
sendBinaryFile(res, full);
});
app.get('/media/audio/line/*', (req, res) => {
const rel = req.params[0] || '';
app.get('/media/audio/line/:relPath(.*)', (req, res) => {
const rel = req.params.relPath || '';
const full = safeRelativeToBase(audioLineDir, rel);
if (!full) return res.status(404).end();
sendBinaryFile(res, full);
});
app.get('/media/audio/station/*', (req, res) => {
const rel = req.params[0] || '';
app.get('/media/audio/station/:relPath(.*)', (req, res) => {
const rel = req.params.relPath || '';
const full = safeRelativeToBase(audioStationDir, rel);
if (!full) return res.status(404).end();
sendBinaryFile(res, full);
});
app.get('/media/temp/*', (req, res) => {
const rel = req.params[0] || '';
app.get('/media/temp/:relPath(.*)', (req, res) => {
const rel = req.params.relPath || '';
const full = safeRelativeToBase(tempBroadcastDir, rel);
if (!full) return res.status(404).end();
sendBinaryFile(res, full);