Skip to content

Commit 64f77ee

Browse files
authored
fix: Allow for trailing slash in supabaseUrl (#262)
* Allow for trailing slash in supabaseUrl * Use for all URLs
1 parent 7ad1d09 commit 64f77ee

File tree

2 files changed

+7
-0
lines changed

2 files changed

+7
-0
lines changed

src/SupabaseClient.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { DEFAULT_HEADERS } from './lib/constants'
2+
import { stripTrailingSlash } from './lib/helpers'
23
import { SupabaseClientOptions } from './lib/types'
34
import { SupabaseAuthClient } from './lib/SupabaseAuthClient'
45
import { SupabaseQueryBuilder } from './lib/SupabaseQueryBuilder'
@@ -51,6 +52,8 @@ export default class SupabaseClient {
5152
if (!supabaseUrl) throw new Error('supabaseUrl is required.')
5253
if (!supabaseKey) throw new Error('supabaseKey is required.')
5354

55+
supabaseUrl = stripTrailingSlash(supabaseUrl)
56+
5457
const settings = { ...DEFAULT_OPTIONS, ...options }
5558
this.restUrl = `${supabaseUrl}/rest/v1`
5659
this.realtimeUrl = `${supabaseUrl}/realtime/v1`.replace('http', 'ws')

src/lib/helpers.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,7 @@ export function uuid() {
77
return v.toString(16)
88
})
99
}
10+
11+
export function stripTrailingSlash(url: string) {
12+
return url.replace(/\/$/, "");
13+
}

0 commit comments

Comments
 (0)