File tree Expand file tree Collapse file tree 1 file changed +15
-7
lines changed Expand file tree Collapse file tree 1 file changed +15
-7
lines changed Original file line number Diff line number Diff line change @@ -60,10 +60,18 @@ export class RequestUrl {
60
60
}
61
61
return emulatorUrl ;
62
62
}
63
- const url = new URL ( this . baseUrl ) ; // Throws if the URL is invalid
64
- url . pathname = `/${ this . apiVersion } /${ this . modelPath } :${ this . task } ` ;
65
- url . search = this . queryParams . toString ( ) ;
66
- return url . toString ( ) ;
63
+
64
+ // Manually construct URL to avoid React Native URL API issues
65
+ let baseUrl = this . baseUrl ;
66
+ // Remove trailing slash if present
67
+ if ( baseUrl . endsWith ( '/' ) ) {
68
+ baseUrl = baseUrl . slice ( 0 , - 1 ) ;
69
+ }
70
+
71
+ const pathname = `/${ this . apiVersion } /${ this . modelPath } :${ this . task } ` ;
72
+ const queryString = this . queryParams ;
73
+
74
+ return `${ baseUrl } ${ pathname } ${ queryString ? `?${ queryString } ` : '' } ` ;
67
75
}
68
76
69
77
private get baseUrl ( ) : string {
@@ -87,10 +95,10 @@ export class RequestUrl {
87
95
}
88
96
}
89
97
90
- private get queryParams ( ) : URLSearchParams {
91
- const params = new URLSearchParams ( ) ;
98
+ private get queryParams ( ) : string {
99
+ let params = '' ;
92
100
if ( this . stream ) {
93
- params . set ( 'alt' , ' sse') ;
101
+ params += 'alt= sse';
94
102
}
95
103
96
104
return params ;
You can’t perform that action at this time.
0 commit comments