- 
                Notifications
    You must be signed in to change notification settings 
- Fork 502
refactor: use URL type for manipulating urls #1417
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
Refactors URL handling in SupabaseClient to use native URL objects and improves header merging in helper defaults.
- Client endpoint properties (realtimeUrl,authUrl, etc.) are nowURLinstances, and consumers call.toString()where needed.
- Deep merge of default and custom headersadded inapplySettingDefaults.
- Old client.test.tsremoved and replaced with a new, more comprehensiveSupabaseClient.test.ts.
Reviewed Changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description | 
|---|---|
| test/helpers.test.ts | Update header assertion to use toStrictEqual | 
| test/client.test.ts | Remove deprecated client tests (superseded by SupabaseClientsuite) | 
| test/SupabaseClient.test.ts | Add comprehensive tests for URL construction, clients, and behaviors | 
| src/lib/helpers.ts | Explicitly merge default and custom headers in applySettingDefaults | 
| src/SupabaseClient.ts | Change endpoint props to URL, useURLAPI for building endpoints, update consumers | 
Comments suppressed due to low confidence (1)
test/helpers.test.ts:39
- Add a unit test case to verify that when global.headersare provided,applySettingDefaultscorrectly merges them with the default headers.
expect(settings.global.headers).toStrictEqual(DEFAULT_HEADERS)
| this.storageUrl = `${_supabaseUrl}/storage/v1` | ||
| this.functionsUrl = `${_supabaseUrl}/functions/v1` | ||
| this.realtimeUrl = new URL('/realtime/v1', baseUrl) | ||
| this.realtimeUrl.protocol = this.realtimeUrl.protocol.replace('http', 'ws') | 
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Was gonna say just do = 'ws:' but I see what you did. ✅
        
          
                src/SupabaseClient.ts
              
                Outdated
          
        
      | */ | ||
| get functions(): FunctionsClient { | ||
| return new FunctionsClient(this.functionsUrl, { | ||
| return new FunctionsClient(this.functionsUrl.toString(), { | 
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Isn't this the right way?
| return new FunctionsClient(this.functionsUrl.toString(), { | |
| return new FunctionsClient(this.functionsUrl.href, { | 
What kind of change does this PR introduce?
Bug fix, feature, docs update, ...
What is the current behavior?
Please link any relevant issues here.
What is the new behavior?
Feel free to include screenshots if it includes visual changes.
Additional context
Add any other context or screenshots.