File tree Expand file tree Collapse file tree 1 file changed +16
-2
lines changed
FirebaseAI/Sources/Types/Internal/Live Expand file tree Collapse file tree 1 file changed +16
-2
lines changed Original file line number Diff line number Diff line change @@ -308,11 +308,12 @@ actor LiveSessionService {
308
308
///
309
309
/// Will apply the required app check and auth headers, as the backend expects them.
310
310
private nonisolated func createWebsocket( ) async throws -> AsyncWebSocket {
311
+ let host = apiConfig. service. endpoint. rawValue. withoutPrefix ( " https:// " )
311
312
let urlString = switch apiConfig. service {
312
313
case . vertexAI:
313
- " wss://firebasevertexai.googleapis.com /ws/google.firebase.vertexai.v1beta.LlmBidiService/BidiGenerateContent/locations/us-central1 "
314
+ " wss:// \( host ) /ws/google.firebase.vertexai.v1beta.LlmBidiService/BidiGenerateContent/locations/us-central1 "
314
315
case . googleAI:
315
- " wss://firebasevertexai.googleapis.com /ws/google.firebase.vertexai.v1beta.GenerativeService/BidiGenerateContent "
316
+ " wss:// \( host ) /ws/google.firebase.vertexai.v1beta.GenerativeService/BidiGenerateContent "
316
317
}
317
318
guard let url = URL ( string: urlString) else {
318
319
throw NSError (
@@ -378,3 +379,16 @@ private extension Data {
378
379
}
379
380
}
380
381
}
382
+
383
+ private extension String {
384
+ /// Create a new string with the given prefix removed, if it's present.
385
+ ///
386
+ /// If the prefix isn't present, this string will be returned instead.
387
+ func withoutPrefix( _ prefix: String ) -> String {
388
+ if let index = range ( of: prefix, options: . anchored) {
389
+ return String ( self [ index. upperBound... ] )
390
+ } else {
391
+ return self
392
+ }
393
+ }
394
+ }
You can’t perform that action at this time.
0 commit comments