File tree Expand file tree Collapse file tree 1 file changed +9
-5
lines changed Expand file tree Collapse file tree 1 file changed +9
-5
lines changed Original file line number Diff line number Diff line change @@ -782,15 +782,19 @@ impl OpenAIClient {
782
782
self . get ( & url) . await
783
783
}
784
784
fn build_url_with_preserved_query ( & self , path : & str ) -> Result < String , url:: ParseError > {
785
- let base = Url :: parse ( & self . api_endpoint ) ?;
786
- let mut url = base. join ( path) ?;
785
+ let ( base, query_opt) = match self . api_endpoint . split_once ( '?' ) {
786
+ Some ( ( b, q) ) => ( b. trim_end_matches ( '/' ) , Some ( q) ) ,
787
+ None => ( self . api_endpoint . trim_end_matches ( '/' ) , None ) ,
788
+ } ;
789
+
790
+ let full_path = format ! ( "{}/{}" , base, path. trim_start_matches( '/' ) ) ;
791
+ let mut url = Url :: parse ( & full_path) ?;
787
792
788
- if let Some ( q ) = base . query ( ) {
789
- for ( k, v) in url:: form_urlencoded:: parse ( q . as_bytes ( ) ) {
793
+ if let Some ( query ) = query_opt {
794
+ for ( k, v) in url:: form_urlencoded:: parse ( query . as_bytes ( ) ) {
790
795
url. query_pairs_mut ( ) . append_pair ( & k, & v) ;
791
796
}
792
797
}
793
-
794
798
Ok ( url. to_string ( ) )
795
799
}
796
800
fn query_params (
You can’t perform that action at this time.
0 commit comments