mirror of
https://github.com/farion1231/cc-switch.git
synced 2026-06-16 13:34:04 +08:00
d19ff09cb7
`build_gemini_native_url` unconditionally stripped `/v1`, `/v1beta`, `/models`, and `/openai` suffixes from the base path regardless of host. This worked for Google's own endpoints but silently rewrote third-party relay URLs like `https://relay.example/custom/v1` to `.../custom/v1beta/models/...`, breaking any relay that mounts its Gemini-compatible namespace under a versioned prefix. The result was also asymmetric with the previously-fixed full-URL branch: toggling the "full URL" switch changed the outbound URL for the same base_url, which is exactly the kind of invisible behavior that makes debugging proxy deployments painful. Align `normalize_gemini_base_path` with `should_normalize_gemini_full_url`'s layered model: - Unconditional: `/models/...:method` structured paths and deep OpenAI-compat endpoints (`/openai/chat/completions`, `/openai/responses` and their versioned variants) — these are unambiguous Gemini-specific grammar on any host. - Google-host gated: generic `/v1`, `/v1beta`, `/models`, `/openai` suffixes only get stripped on `generativelanguage.googleapis.com`, `aiplatform.googleapis.com`, or `*-aiplatform.googleapis.com`. Other hosts preserve the prefix verbatim so relays keep their intended routing. Adds seven regression tests for the non-full-URL flow: opaque relay preservation (v1 / v1beta / models / openai suffix variants), Google host normalization (counter-case), and boundary cases (structured method path and deep OpenAI-compat endpoint stripped regardless of host). Test count: 864 -> 873.
d19ff09cb7
·
2026-04-16 21:20:59 +08:00
History