平台层转发 base_url 前去掉首尾空白

- server-rs/crates/platform-tripo/src/common/config.rs:client_options 里 base_url 先 trim 再交给 SDK,带空白的地址不再以低层解析错误的形式暴露出来
- server-rs/crates/platform-tripo/src/common/config.rs:把 client_options 的用例扩到 base_url,锁住「校验看到的」与「发出去的」是同一个值
This commit is contained in:
2026-09-24 17:58:03 +08:00
parent 80ae730dc5
commit ebce5f9304
@@ -101,7 +101,9 @@ impl TripoSettings {
// 校验用的是 trim 后的值,发出去的也必须是 trim 后的值:密钥被复制时带上
// 首尾空白,就会在 provider 那边变成一个看不懂的 401。
api_key: Some(self.api_key.trim().to_string()),
base_url: Some(self.base_url.clone()),
// 与 base_url 校验同口径:校验看的是 trim 后的值,发出去的也得是 trim 后的值,
// 否则带空白的地址会在 SDK 里以低层解析错误暴露出来。
base_url: Some(self.base_url.trim().to_string()),
timeout: Some(self.request_timeout),
retries: Some(self.retries),
user_agent: Some(self.user_agent.clone()),
@@ -187,9 +189,14 @@ mod tests {
#[test]
fn client_options_trim_credentials_that_validation_trimmed() {
let options =
settings(Duration::from_secs(1), " key ", "https://example.com").client_options();
let options = settings(
Duration::from_secs(1),
" key ",
" https://example.com/v3 ",
)
.client_options();
assert_eq!(options.api_key.as_deref(), Some("key"));
assert_eq!(options.base_url.as_deref(), Some("https://example.com/v3"));
}
}