File tree Expand file tree Collapse file tree 3 files changed +20
-7
lines changed Expand file tree Collapse file tree 3 files changed +20
-7
lines changed Original file line number Diff line number Diff line change @@ -62,13 +62,13 @@ export default class SupabaseClient {
62
62
if ( ! supabaseUrl ) throw new Error ( 'supabaseUrl is required.' )
63
63
if ( ! supabaseKey ) throw new Error ( 'supabaseKey is required.' )
64
64
65
- supabaseUrl = stripTrailingSlash ( supabaseUrl )
66
-
65
+ const _supabaseUrl = stripTrailingSlash ( supabaseUrl )
67
66
const settings = { ...DEFAULT_OPTIONS , ...options }
68
- this . restUrl = `${ supabaseUrl } /rest/v1`
69
- this . realtimeUrl = `${ supabaseUrl } /realtime/v1` . replace ( 'http' , 'ws' )
70
- this . authUrl = `${ supabaseUrl } /auth/v1`
71
- this . storageUrl = `${ supabaseUrl } /storage/v1`
67
+
68
+ this . restUrl = `${ _supabaseUrl } /rest/v1`
69
+ this . realtimeUrl = `${ _supabaseUrl } /realtime/v1` . replace ( 'http' , 'ws' )
70
+ this . authUrl = `${ _supabaseUrl } /auth/v1`
71
+ this . storageUrl = `${ _supabaseUrl } /storage/v1`
72
72
this . schema = settings . schema
73
73
this . multiTab = settings . multiTab
74
74
this . fetch = settings . fetch
Original file line number Diff line number Diff line change @@ -8,7 +8,7 @@ export function uuid() {
8
8
} )
9
9
}
10
10
11
- export function stripTrailingSlash ( url : string ) {
11
+ export function stripTrailingSlash ( url : string ) : string {
12
12
return url . replace ( / \/ $ / , '' )
13
13
}
14
14
Original file line number Diff line number Diff line change
1
+ import { stripTrailingSlash } from '../src/lib/helpers'
2
+
3
+ test ( 'Strip trailing slash from URL' , ( ) => {
4
+ const URL = 'http://localhost:3000/'
5
+ const expectedURL = URL . slice ( 0 , - 1 )
6
+ expect ( stripTrailingSlash ( URL ) ) . toBe ( expectedURL )
7
+ } )
8
+
9
+ test ( 'Return the original URL if there is no slash at the end' , ( ) => {
10
+ const URL = 'http://localhost:3000'
11
+ const expectedURL = URL
12
+ expect ( stripTrailingSlash ( URL ) ) . toBe ( expectedURL )
13
+ } )
You can’t perform that action at this time.
0 commit comments