From ffc0a213c1cbb4c870c26247b49c7d18dce3eea4 Mon Sep 17 00:00:00 2001 From: FaintGhost Date: Thu, 29 Oct 2026 17:04:38 +0100 Subject: [PATCH] =?UTF-8?q?fix(producers):=20=E8=A1=A5=E5=85=A8=20clash=20?= =?UTF-8?q?=E7=9B=AE=E6=A0=87=E7=9A=84=E5=B0=8F=E5=86=99=E5=88=AB=E5=90=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 生产者注册表里其它目标都同时提供大小写别名(surge/Surge、uri/URI、 json/JSON、stash/Stash、egern/Egern…),只有 Clash 缺少小写的 clash。 结果是通过 `?target=clash` 或 `?platform=clash` 请求订阅时, 后端抛出 `Target platform: clash is not supported!` 并返回 500, 而 `?target=Clash` 正常。UA 映射本身返回的也是 'Clash',所以只有 显式指定小写 target 的客户端会踩到。 补上 `clash: Clash_Producer()`,与其它目标保持一致。 --- .../src/core/proxy-utils/producers/index.js | 1 + .../test/proxy-producers/target-alias.spec.js | 35 +++++++++++++++++++ 2 files changed, 36 insertions(+) create mode 100644 backend/src/test/proxy-producers/target-alias.spec.js diff --git a/backend/src/core/proxy-utils/producers/index.js b/backend/src/core/proxy-utils/producers/index.js index 2915a775..8b256914 100644 --- a/backend/src/core/proxy-utils/producers/index.js +++ b/backend/src/core/proxy-utils/producers/index.js @@ -28,6 +28,7 @@ export default { SurgeMac: SurgeMac_Producer(), Loon: Loon_Producer(), Clash: Clash_Producer(), + clash: Clash_Producer(), meta: ClashMeta_Producer(), clashmeta: ClashMeta_Producer(), 'clash.meta': ClashMeta_Producer(), diff --git a/backend/src/test/proxy-producers/target-alias.spec.js b/backend/src/test/proxy-producers/target-alias.spec.js new file mode 100644 index 00000000..38e930cd --- /dev/null +++ b/backend/src/test/proxy-producers/target-alias.spec.js @@ -0,0 +1,35 @@ +import { expect } from 'chai'; +import { describe, it } from 'mocha'; + +import { ProxyUtils } from '@/core/proxy-utils'; +import { produceExternal } from './helpers'; + +const PROXY = { + type: 'ss', + name: 'SS Node', + server: '1.2.3.4', + port: 443, + cipher: 'aes-128-gcm', + password: 'secret', +}; + +describe('Proxy target aliases', function () { + it('produces the same output for lowercase and capitalized target names', function () { + const cases = [ + ['clash', 'Clash'], + ['meta', 'ClashMeta'], + ['mihomo', 'ClashMeta'], + ['uri', 'URI'], + ['v2ray', 'V2Ray'], + ['json', 'JSON'], + ['stash', 'Stash'], + ['egern', 'Egern'], + ['sing-box', 'sing-box'], + ]; + for (const [lower, canonical] of cases) { + expect(produceExternal(lower, [PROXY]), lower).to.equal( + produceExternal(canonical, [PROXY]), + ); + } + }); +});