mirror of
https://github.com/openai/codex.git
synced 2026-11-28 23:34:06 +00:00
Honor the configured ChatGPT origin in connector install URLs (#37338)
## What changed - Build connector install URLs from `CODEX_APP_SERVER_CHATGPT_BASE_URL`, falling back to `https://chatgpt.com` when it is unset. - Strip a trailing slash or `/backend-api` suffix before appending the `/apps/<slug>/<connector-id>` path. - Add a test covering install URL generation with the configured origin. GitOrigin-RevId: 854d15b7e322d2359684f974aaf27fe28205dd5a
This commit is contained in:
1 parent
b3ffe3d001
commit
842547640e
1 file changed
+19
-1
@@ -480,8 +480,13 @@ fn directory_app_to_app_info(app: DirectoryApp) -> AppInfo {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn connector_install_url(name: &str, connector_id: &str) -> String {
|
fn connector_install_url(name: &str, connector_id: &str) -> String {
|
||||||
|
let chatgpt_base_url = std::env::var("CODEX_APP_SERVER_CHATGPT_BASE_URL")
|
||||||
|
.unwrap_or_else(|_| "https://chatgpt.com".to_string());
|
||||||
|
let chatgpt_origin = chatgpt_base_url
|
||||||
|
.trim_end_matches('/')
|
||||||
|
.trim_end_matches("/backend-api");
|
||||||
let slug = connector_name_slug(name);
|
let slug = connector_name_slug(name);
|
||||||
format!("https://chatgpt.com/apps/{slug}/{connector_id}")
|
format!("{chatgpt_origin}/apps/{slug}/{connector_id}")
|
||||||
}
|
}
|
||||||
|
|
||||||
fn connector_name_slug(name: &str) -> String {
|
fn connector_name_slug(name: &str) -> String {
|
||||||
@@ -569,6 +574,19 @@ mod tests {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn connector_install_url_uses_configured_origin() {
|
||||||
|
let chatgpt_base_url = std::env::var("CODEX_APP_SERVER_CHATGPT_BASE_URL")
|
||||||
|
.unwrap_or_else(|_| "https://chatgpt.com".to_string());
|
||||||
|
let chatgpt_origin = chatgpt_base_url
|
||||||
|
.trim_end_matches('/')
|
||||||
|
.trim_end_matches("/backend-api");
|
||||||
|
assert_eq!(
|
||||||
|
connector_install_url("Google Calendar", "calendar"),
|
||||||
|
format!("{chatgpt_origin}/apps/google-calendar/calendar"),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn directory_app_icon_assets_reach_app_info() -> anyhow::Result<()> {
|
fn directory_app_icon_assets_reach_app_info() -> anyhow::Result<()> {
|
||||||
let response: DirectoryListResponse = serde_json::from_value(serde_json::json!({
|
let response: DirectoryListResponse = serde_json::from_value(serde_json::json!({
|
||||||
|
|||||||
Reference in new issue
Block a user