feat: 增强 mihomo 输入的兼容性

This commit is contained in:
xream committed 2026-07-24 18:45:31 +08:00
1 parent 8b49cf5afa
commit c9d0e7e453
2 files changed
+28 -1

No files matched your search

+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "sub-store",
"version": "2.36.20",
"version": "2.36.21",
"description": "Advanced Subscription Manager for QX, Loon, Surge, Stash and Shadowrocket.",
"main": "src/main.js",
"packageManager": "pnpm@11.0.9",
+27
View File
@@ -719,6 +719,33 @@ function formatTransportPath(path) {
}
function lastParse(proxy) {
// normalize keys to lowercase for all -opts keys and their subkeys
// 通常来说够用了, 在重构之前暂不考虑引入更复杂的逻辑
const hasOwn = (value, key) =>
Object.prototype.hasOwnProperty.call(value, key);
const normalizeOpts = (value) => {
if (!value || typeof value !== 'object' || Array.isArray(value)) return;
for (const key of Object.keys(value)) {
const normalizedKey = key.toLowerCase();
if (key !== normalizedKey) {
if (!hasOwn(value, normalizedKey)) {
value[normalizedKey] = value[key];
}
delete value[key];
}
}
};
for (const key of Object.keys(proxy)) {
const normalizedKey = key.toLowerCase();
if (!normalizedKey.endsWith('-opts')) continue;
if (key !== normalizedKey) {
if (!hasOwn(proxy, normalizedKey)) {
proxy[normalizedKey] = proxy[key];
}
delete proxy[key];
}
normalizeOpts(proxy[normalizedKey]);
}
proxy.udp = ![false, 0, '0', 'false', 'off'].includes(
typeof proxy.udp === 'string' ? proxy.udp.toLowerCase() : proxy.udp,
);