修复(API接口): 优化线路名称匹配逻辑并升级版本至1.0.17

移除线路名称中的所有多余空格,增强匹配鲁棒性,修复带有额外空格的线路无法正确匹配的问题
This commit is contained in:
2026-07-10 13:15:45 +08:00
parent 8b10117487
commit 2e113232d9
2 changed files with 4 additions and 4 deletions
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "ticketmachine",
"version": "1.0.16",
"version": "1.0.17",
"main": "server/index.js",
"scripts": {
"start": "node server/index.js",
+3 -3
View File
@@ -1340,11 +1340,11 @@ router.post('/tickets/check', async (req, res) => {
const checkStationOnLine = (lineName, codeRaw, codesSet, codeNorm) => {
if (!lineName) return false;
const target = String(lineName).trim().toLowerCase();
const target = String(lineName).trim().toLowerCase().replace(/\s+/g, '');
const lines = DataService.getLines() || [];
const line = lines.find(l => {
const ln = String(l.name || l['线路名称'] || '').trim().toLowerCase();
const le = String(l.en_name || l.en || l.enName || '').trim().toLowerCase();
const ln = String(l.name || l['线路名称'] || '').trim().toLowerCase().replace(/\s+/g, '');
const le = String(l.en_name || l.en || l.enName || '').trim().toLowerCase().replace(/\s+/g, '');
return ln === target || le === target;
});
if (!line) return false; // Line not found