From ca2274791b134c7067a69d941b3d3d0990506757 Mon Sep 17 00:00:00 2001 From: Orion Date: Wed, 3 Jun 2026 15:20:57 +0800 Subject: [PATCH] =?UTF-8?q?=E2=9A=A1fix(core):=20=E4=BC=98=E5=8C=96=20SubS?= =?UTF-8?q?tore=20=E8=8A=82=E7=82=B9=E9=87=8D=E5=91=BD=E5=90=8D=E8=A7=84?= =?UTF-8?q?=E5=88=99=E4=B8=8E=E9=94=99=E4=BD=8D=E5=8C=B9=E9=85=8D=E9=80=BB?= =?UTF-8?q?=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- substore/common.js | 21 ++++++++++++++++++++- substore/rename.js | 7 ++++++- 2 files changed, 26 insertions(+), 2 deletions(-) diff --git a/substore/common.js b/substore/common.js index 76dcdbd..ccdefe9 100644 --- a/substore/common.js +++ b/substore/common.js @@ -192,6 +192,19 @@ }; const normalizeHyphenatedRegionFeatures = name => { + const misplacedSequenceMatch = String(name).match(/^([A-Z]{2}(?:\s+[A-Z]{3})?)\s+01\s+(\d{1,2})-(.+)$/); + if (misplacedSequenceMatch) { + return [ + misplacedSequenceMatch[1], + misplacedSequenceMatch[2].padStart(2, '0'), + misplacedSequenceMatch[3].trim() + ] + .filter(Boolean) + .join(' ') + .replace(/\s{2,}/g, ' ') + .trim(); + } + const hyphenatedMatch = String(name).match(/^([A-Z]{2})(?:\s+([A-Z]{3}))?-(.+)$/); if (!hyphenatedMatch) return name; @@ -211,7 +224,13 @@ } const sequenceIndex = tokens.findIndex(token => /^\d{1,2}$/.test(token)); - if (sequenceIndex === -1) return name; + if (sequenceIndex === -1) { + return [regionCode, tokens.join('-')] + .filter(Boolean) + .join(' ') + .replace(/\s{2,}/g, ' ') + .trim(); + } const sequenceNumber = tokens[sequenceIndex].padStart(2, '0'); const ingressTokens = tokens diff --git a/substore/rename.js b/substore/rename.js index 5986ee1..9864573 100644 --- a/substore/rename.js +++ b/substore/rename.js @@ -773,7 +773,12 @@ async function operator(proxies) { core = normalizeRegionSequence(normalizeHyphenatedRegionFeatures(moveMultiplierToEnd(simplifyCoreName(core)))) .replace(/^([A-Z]{2}(?:\s+[A-Z]{3})?\s+\d{2}\s+(?:标准|高级))\s+1(?=$|\s)/i, '$1'); - return flag ? `${flag} ${core}` : core; + const coreRegionCode = leadingCodeOf(core); + const outputFlag = flag && knownRegionCodes.has(coreRegionCode) + ? utils.regionCodeToFlag(coreRegionCode) || flag + : flag; + + return outputFlag ? `${outputFlag} ${core}` : core; }; proxies.forEach((proxy, proxyIndex) => {