-
-
Notifications
You must be signed in to change notification settings - Fork 366
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 nowURL
instances, and consumers call.toString()
where needed. - Deep merge of default and custom
headers
added inapplySettingDefaults
. - Old
client.test.ts
removed 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 SupabaseClient suite) |
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 , use URL API 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.headers
are provided,applySettingDefaults
correctly 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
@@ -137,7 +139,7 @@ export default class SupabaseClient< | |||
* Supabase Functions allows you to deploy and invoke edge functions. | |||
*/ | |||
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.