修复(API接口): 优化线路名称匹配逻辑并升级版本至1.0.17
移除线路名称中的所有多余空格,增强匹配鲁棒性,修复带有额外空格的线路无法正确匹配的问题
This commit is contained in:
+1
-1
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "ticketmachine",
|
"name": "ticketmachine",
|
||||||
"version": "1.0.16",
|
"version": "1.0.17",
|
||||||
"main": "server/index.js",
|
"main": "server/index.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"start": "node server/index.js",
|
"start": "node server/index.js",
|
||||||
|
|||||||
@@ -1340,11 +1340,11 @@ router.post('/tickets/check', async (req, res) => {
|
|||||||
|
|
||||||
const checkStationOnLine = (lineName, codeRaw, codesSet, codeNorm) => {
|
const checkStationOnLine = (lineName, codeRaw, codesSet, codeNorm) => {
|
||||||
if (!lineName) return false;
|
if (!lineName) return false;
|
||||||
const target = String(lineName).trim().toLowerCase();
|
const target = String(lineName).trim().toLowerCase().replace(/\s+/g, '');
|
||||||
const lines = DataService.getLines() || [];
|
const lines = DataService.getLines() || [];
|
||||||
const line = lines.find(l => {
|
const line = lines.find(l => {
|
||||||
const ln = String(l.name || l['线路名称'] || '').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();
|
const le = String(l.en_name || l.en || l.enName || '').trim().toLowerCase().replace(/\s+/g, '');
|
||||||
return ln === target || le === target;
|
return ln === target || le === target;
|
||||||
});
|
});
|
||||||
if (!line) return false; // Line not found
|
if (!line) return false; // Line not found
|
||||||
|
|||||||
Reference in New Issue
Block a user