Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions src/SupabaseClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,13 +62,13 @@ export default class SupabaseClient {
if (!supabaseUrl) throw new Error('supabaseUrl is required.')
if (!supabaseKey) throw new Error('supabaseKey is required.')

supabaseUrl = stripTrailingSlash(supabaseUrl)

const _supabaseUrl = stripTrailingSlash(supabaseUrl)
const settings = { ...DEFAULT_OPTIONS, ...options }
this.restUrl = `${supabaseUrl}/rest/v1`
this.realtimeUrl = `${supabaseUrl}/realtime/v1`.replace('http', 'ws')
this.authUrl = `${supabaseUrl}/auth/v1`
this.storageUrl = `${supabaseUrl}/storage/v1`

this.restUrl = `${_supabaseUrl}/rest/v1`
this.realtimeUrl = `${_supabaseUrl}/realtime/v1`.replace('http', 'ws')
this.authUrl = `${_supabaseUrl}/auth/v1`
this.storageUrl = `${_supabaseUrl}/storage/v1`
this.schema = settings.schema
this.multiTab = settings.multiTab
this.fetch = settings.fetch
Expand Down
2 changes: 1 addition & 1 deletion src/lib/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export function uuid() {
})
}

export function stripTrailingSlash(url: string) {
export function stripTrailingSlash(url: string): string {
return url.replace(/\/$/, '')
}

Expand Down
13 changes: 13 additions & 0 deletions test/helper.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import { stripTrailingSlash } from '../src/lib/helpers'

test('Strip trailing slash from URL', () => {
const URL = 'http://localhost:3000/'
const expectedURL = URL.slice(0, -1)
expect(stripTrailingSlash(URL)).toBe(expectedURL)
})

test('Return the original URL if there is no slash at the end', () => {
const URL = 'http://localhost:3000'
const expectedURL = URL
expect(stripTrailingSlash(URL)).toBe(expectedURL)
})