Skip to content

Commit 00b9e7d

Browse files
authored
feat: edge functions support for custom domains and vanity domains (#90)
1 parent 3c5af19 commit 00b9e7d

File tree

2 files changed

+3
-30
lines changed

2 files changed

+3
-30
lines changed

Sources/Supabase/SupabaseClient.swift

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ public class SupabaseClient {
7272
storageURL = supabaseURL.appendingPathComponent("/storage/v1")
7373
databaseURL = supabaseURL.appendingPathComponent("/rest/v1")
7474
realtimeURL = supabaseURL.appendingPathComponent("/realtime/v1")
75+
functionsURL = supabaseURL.appendingPathComponent("/functions/v1")
7576

7677
schema = options.db.schema
7778
httpClient = options.global.httpClient
@@ -87,16 +88,6 @@ public class SupabaseClient {
8788
headers: defaultHeaders,
8889
localStorage: options.auth.storage
8990
)
90-
91-
let isPlatform =
92-
supabaseURL.absoluteString.contains("supabase.co")
93-
|| supabaseURL.absoluteString.contains("supabase.in")
94-
if isPlatform {
95-
let urlParts = supabaseURL.absoluteString.split(separator: ".")
96-
functionsURL = URL(string: "\(urlParts[0]).functions.\(urlParts[1]).\(urlParts[2])")!
97-
} else {
98-
functionsURL = supabaseURL.appendingPathComponent("functions/v1")
99-
}
10091
}
10192

10293
public struct HTTPClient {

Tests/SupabaseTests/SupabaseClientTests.swift

Lines changed: 2 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@ final class SupabaseClientTests: XCTestCase {
3838
XCTAssertEqual(client.storageURL.absoluteString, "https://project-ref.supabase.co/storage/v1")
3939
XCTAssertEqual(client.databaseURL.absoluteString, "https://project-ref.supabase.co/rest/v1")
4040
XCTAssertEqual(client.realtimeURL.absoluteString, "https://project-ref.supabase.co/realtime/v1")
41+
XCTAssertEqual(client.functionsURL.absoluteString, "https://project-ref.supabase.co/functions/v1")
42+
4143
XCTAssertEqual(
4244
client.defaultHeaders,
4345
[
@@ -48,24 +50,4 @@ final class SupabaseClientTests: XCTestCase {
4850
]
4951
)
5052
}
51-
52-
func testFunctionsURL() {
53-
var client = SupabaseClient(
54-
supabaseURL: URL(string: "https://project-ref.supabase.co")!,
55-
supabaseKey: "ANON_KEY"
56-
)
57-
XCTAssertEqual(client.functionsURL.absoluteString, "https://project-ref.functions.supabase.co")
58-
59-
client = SupabaseClient(
60-
supabaseURL: URL(string: "https://project-ref.supabase.in")!,
61-
supabaseKey: "ANON_KEY"
62-
)
63-
XCTAssertEqual(client.functionsURL.absoluteString, "https://project-ref.functions.supabase.in")
64-
65-
client = SupabaseClient(
66-
supabaseURL: URL(string: "https://custom-domain.com")!,
67-
supabaseKey: "ANON_KEY"
68-
)
69-
XCTAssertEqual(client.functionsURL.absoluteString, "https://custom-domain.com/functions/v1")
70-
}
7153
}

0 commit comments

Comments
 (0)