ios: fix api endpoint change
This commit is contained in:
@@ -35,7 +35,7 @@ Instructions for work under `/Users/buzzert/src/sybil-2/ios`.
|
||||
|
||||
## Practical Notes
|
||||
- Default API URL is `http://127.0.0.1:8787` (configurable in-app).
|
||||
- Previously saved `/api` API roots are normalized to the server root by the iOS client.
|
||||
- The iOS client preserves an explicit `/api` base path for proxied deployments.
|
||||
- Provider fallback models:
|
||||
- OpenAI: `gpt-4.1-mini`
|
||||
- Anthropic: `claude-3-5-sonnet-latest`
|
||||
|
||||
@@ -21,12 +21,14 @@ actor SybilAPIClient {
|
||||
private let configuration: APIConfiguration
|
||||
private let session: URLSession
|
||||
|
||||
@MainActor
|
||||
private static let iso8601FormatterWithFractional: ISO8601DateFormatter = {
|
||||
let formatter = ISO8601DateFormatter()
|
||||
formatter.formatOptions = [.withInternetDateTime, .withFractionalSeconds]
|
||||
return formatter
|
||||
}()
|
||||
|
||||
|
||||
@MainActor
|
||||
private static let iso8601Formatter: ISO8601DateFormatter = {
|
||||
let formatter = ISO8601DateFormatter()
|
||||
formatter.formatOptions = [.withInternetDateTime]
|
||||
|
||||
@@ -72,11 +72,6 @@ final class SybilSettingsStore {
|
||||
return nil
|
||||
}
|
||||
|
||||
let path = components.path.trimmingCharacters(in: CharacterSet(charactersIn: "/"))
|
||||
if path.lowercased() == "api" {
|
||||
components.path = ""
|
||||
}
|
||||
|
||||
return components.url
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,24 @@
|
||||
import Testing
|
||||
@testable import Sybil
|
||||
|
||||
@Test func example() async throws {
|
||||
// Write your test here and use APIs like `#expect(...)` to check expected conditions.
|
||||
@MainActor
|
||||
@Test func normalizedAPIBaseURLPreservesExplicitAPIPath() async throws {
|
||||
let defaults = UserDefaults(suiteName: #function)!
|
||||
defaults.removePersistentDomain(forName: #function)
|
||||
|
||||
let settings = SybilSettingsStore(defaults: defaults)
|
||||
settings.apiBaseURL = "https://sybil.bajor.cloud/api/"
|
||||
|
||||
#expect(settings.normalizedAPIBaseURL?.absoluteString == "https://sybil.bajor.cloud/api")
|
||||
}
|
||||
|
||||
@MainActor
|
||||
@Test func normalizedAPIBaseURLTrimsWhitespaceAndTrailingSlashes() async throws {
|
||||
let defaults = UserDefaults(suiteName: #function)!
|
||||
defaults.removePersistentDomain(forName: #function)
|
||||
|
||||
let settings = SybilSettingsStore(defaults: defaults)
|
||||
settings.apiBaseURL = " http://127.0.0.1:8787/// "
|
||||
|
||||
#expect(settings.normalizedAPIBaseURL?.absoluteString == "http://127.0.0.1:8787")
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user