mirror of
https://github.com/farion1231/cc-switch.git
synced 2026-07-29 09:37:37 +08:00
fix(claude): improve backward compatibility for openrouter_compat_mode
Extend backward compatibility support for legacy openrouter_compat_mode field:
- Support number type (1 = enabled, 0 = disabled)
- Support string type ("true"/"1" = enabled)
- Add corresponding test cases for number and string types
This commit is contained in:
@@ -517,6 +517,24 @@ mod tests {
|
||||
}));
|
||||
assert!(adapter.needs_transform(&legacy_compat_enabled));
|
||||
|
||||
// Backward compatibility: openrouter_compat_mode=1 should enable transform
|
||||
let legacy_compat_enabled_num = create_provider(json!({
|
||||
"env": {
|
||||
"ANTHROPIC_BASE_URL": "https://api.example.com"
|
||||
},
|
||||
"openrouter_compat_mode": 1
|
||||
}));
|
||||
assert!(adapter.needs_transform(&legacy_compat_enabled_num));
|
||||
|
||||
// Backward compatibility: openrouter_compat_mode="true" should enable transform
|
||||
let legacy_compat_enabled_str = create_provider(json!({
|
||||
"env": {
|
||||
"ANTHROPIC_BASE_URL": "https://api.example.com"
|
||||
},
|
||||
"openrouter_compat_mode": "true"
|
||||
}));
|
||||
assert!(adapter.needs_transform(&legacy_compat_enabled_str));
|
||||
|
||||
// Backward compatibility: openrouter_compat_mode=false should not enable transform
|
||||
let legacy_compat_disabled = create_provider(json!({
|
||||
"env": {
|
||||
|
||||
Reference in New Issue
Block a user