Support model names containing / without URL encoding#2
Draft
Copilot wants to merge 3 commits into
Draft
Conversation
Co-authored-by: yinxulai <22045569+yinxulai@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Fix model name support for slashes in model identifiers
Support model names containing Mar 10, 2026
/ via URL percent-encoding
Owner
|
@copilot |
Co-authored-by: yinxulai <22045569+yinxulai@users.noreply.github.com>
Author
支持了。新增了 # z-ai/glm4.7 直接放在 /~/ 后面,无需编码
export ANTHROPIC_BASE_URL=https://claude-proxy.yinxulai.com/https/api.example.com/v1/~/z-ai/glm4.7代理收到
原有格式(模型名作为最后一段路径)以及 Warning Firewall rules blocked me from connecting to one or more addresses (expand for details)I tried to connect to the following addresses, but was blocked by firewall rules:
If you need me to access, download, or install something from one of these locations, you can either:
|
Copilot
AI
changed the title
Support model names containing
Support model names containing Mar 10, 2026
/ via URL percent-encoding/ without URL encoding
Owner
|
@copilot 给我提出几个实现方案,我希望的方案是对用户影响最小的那种,最好是可以保持当前用法完全不影响用户那种 |
Author
以下是几种可行方案,从对现有用户影响最大到最小排列: 方案 A:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
parsePathAndModel()splits the URL pathname on/to extract the model name as the last segment, making model names likez-ai/glm4.7impossible to express — the slash is consumed as a path separator.Changes
source/proxy.ts— Added a/~/tilde-separator format that explicitly marks where the base URL ends and the model name begins, allowing any characters (including/) in the model name without encoding. The legacy last-segment format is preserved for backward compatibility, withdecodeURIComponent()so%2F-encoded slashes also continue to work.test/dynamic-routing.test.ts— Added tests for both the new/~/separator format and the legacy%2Fpercent-encoding format, including assertions that the upstream API is called with the correct base URL and decoded model name.README.md— Documented both URL formats with examples in the provider table and quick-start section.URL Formats
Two formats are supported:
New tilde-separator format (recommended — no encoding required):
Legacy format (backward-compatible —
%2Fencoding still works):In the tilde-separator format, everything between
/~/and/v1/messagesis treated as the model name, so slashes in model names require no special treatment.Original prompt
🔒 GitHub Advanced Security automatically protects Copilot coding agent pull requests. You can protect all pull requests by enabling Advanced Security for your repositories. Learn more about Advanced Security.