♻️ refactor(substore): 优化节点重命名规则并规范化地区序列号格式
This commit is contained in:
@@ -1,6 +1,6 @@
|
|||||||
/**
|
/**
|
||||||
* PeiQian 专用节点清理脚本
|
* PeiQian 专用节点清理脚本
|
||||||
* 负责清理推荐、用途、hy2、倍率等 PeiQian 节点文案。
|
* 负责清理推荐、用途、hy2、倍率、线路特征和提供商等 PeiQian 节点文案。
|
||||||
*/
|
*/
|
||||||
// noinspection JSUnusedGlobalSymbols
|
// noinspection JSUnusedGlobalSymbols
|
||||||
function operator(proxies) {
|
function operator(proxies) {
|
||||||
@@ -10,21 +10,15 @@ function operator(proxies) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
proxy.name = proxy.name
|
proxy.name = proxy.name
|
||||||
.replace(/^AWS\s*新加坡\s*/i, '新加坡 AWS ')
|
.replace(/AWS\s*新加坡\s*/gi, '')
|
||||||
.replace(/\s*\|\s*合适下载使用\s*-\s*(\d+(?:\.\d+)?)倍/gi, ' $1x')
|
.replace(/\s*\|\s*合适下载使用\s*-\s*(\d+(?:\.\d+)?)倍/gi, ' $1x')
|
||||||
.replace(/\s*\|\s*合适下载使用/gi, '')
|
.replace(/\s*\|\s*合适下载使用/gi, '')
|
||||||
.replace(/\s*\|\s*避免晚高峰使用/gi, '')
|
.replace(/\s*\|\s*避免晚高峰使用/gi, '')
|
||||||
.replace(/\s*\|\s*电信联通移动推荐\s*-\s*hy2/gi, ' [三网 HY2]')
|
.replace(/\s*\|\s*(?:电信联通移动|电信联通|移动联通|三网)推荐(?:\s*-\s*hy2)?/gi, '')
|
||||||
.replace(/\s*\|\s*电信联通移动推荐/gi, ' [三网]')
|
.replace(/\s*\|\s*高速专线(?:推荐)?(?:\s*-\s*hy2)?/gi, '')
|
||||||
.replace(/\s*\|\s*电信联通推荐\s*-\s*hy2/gi, ' [电联 HY2]')
|
|
||||||
.replace(/\s*\|\s*电信联通推荐/gi, ' [电联]')
|
|
||||||
.replace(/\s*\|\s*移动联通推荐\s*-\s*hy2/gi, ' [移联 HY2]')
|
|
||||||
.replace(/\s*\|\s*移动联通推荐/gi, ' [移联]')
|
|
||||||
.replace(/\s*\|\s*高速专线(?:推荐)?\s*-\s*hy2/gi, ' [HY2]')
|
|
||||||
.replace(/\s*\|\s*高速专线推荐/gi, ' [专线]')
|
|
||||||
.replace(/\s*\|\s*三网推荐/gi, ' [三网]')
|
|
||||||
.replace(/-\s*(\d+(?:\.\d+)?)倍/gi, ' $1x')
|
.replace(/-\s*(\d+(?:\.\d+)?)倍/gi, ' $1x')
|
||||||
.replace(/(\d+(?:\.\d+)?)倍/gi, '$1x')
|
.replace(/(\d+(?:\.\d+)?)倍/gi, '$1x')
|
||||||
|
.replace(/\s*\[(?:专线|移联|电联|三网|HY2)(?:\s+(?:专线|移联|电联|三网|HY2))*\]/gi, '')
|
||||||
.replace(/\s+\[/g, ' [')
|
.replace(/\s+\[/g, ' [')
|
||||||
.replace(/\s{2,}/g, ' ')
|
.replace(/\s{2,}/g, ' ')
|
||||||
.trim();
|
.trim();
|
||||||
|
|||||||
+14
-1
@@ -676,6 +676,19 @@ function operator(proxies) {
|
|||||||
return `${nameWithoutMultiplier} ${multipliers.join(' ')}`.trim();
|
return `${nameWithoutMultiplier} ${multipliers.join(' ')}`.trim();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const normalizeRegionSequence = name => name
|
||||||
|
.replace(/(^|\s)([A-Z]{2}(?:\s+[A-Z]{3})?)[\s|\-]*(\d{1,2})(?=$|[\s|\-[\]])/g, (
|
||||||
|
match,
|
||||||
|
prefix,
|
||||||
|
regionCode,
|
||||||
|
sequenceNumber
|
||||||
|
) => {
|
||||||
|
return `${prefix}${regionCode} ${sequenceNumber.padStart(2, '0')}`;
|
||||||
|
})
|
||||||
|
.replace(/(\b[A-Z]{2}(?:\s+[A-Z]{3})? \d{2})-\s*(?=\d+(?:\.\d+)?X\b)/g, '$1 ')
|
||||||
|
.replace(/\s{2,}/g, ' ')
|
||||||
|
.trim();
|
||||||
|
|
||||||
const normalizeBilingualName = name => {
|
const normalizeBilingualName = name => {
|
||||||
const bilingualMatch = name.match(/^(.+?)\s*|\s*(.+)$/);
|
const bilingualMatch = name.match(/^(.+?)\s*|\s*(.+)$/);
|
||||||
if (!bilingualMatch) return name;
|
if (!bilingualMatch) return name;
|
||||||
@@ -740,7 +753,7 @@ function operator(proxies) {
|
|||||||
core = joinAlias(flagRegionCode, core);
|
core = joinAlias(flagRegionCode, core);
|
||||||
}
|
}
|
||||||
|
|
||||||
core = moveMultiplierToEnd(simplifyCoreName(core));
|
core = normalizeRegionSequence(moveMultiplierToEnd(simplifyCoreName(core)));
|
||||||
|
|
||||||
return flag ? `${flag} ${core}` : core;
|
return flag ? `${flag} ${core}` : core;
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user