Skip to content

Conversation

@grdsdev
Copy link
Contributor

@grdsdev grdsdev commented May 19, 2025

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.

@grdsdev grdsdev requested review from Copilot and hf May 19, 2025 14:46
Copy link
Contributor

Copilot AI left a 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 now URL instances, and consumers call .toString() where needed.
  • Deep merge of default and custom headers added in applySettingDefaults.
  • Old client.test.ts removed and replaced with a new, more comprehensive SupabaseClient.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')
Copy link
Contributor

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. ✅

*/
get functions(): FunctionsClient {
return new FunctionsClient(this.functionsUrl, {
return new FunctionsClient(this.functionsUrl.toString(), {
Copy link
Contributor

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?

Suggested change
return new FunctionsClient(this.functionsUrl.toString(), {
return new FunctionsClient(this.functionsUrl.href, {

@grdsdev grdsdev merged commit bc4bce1 into master May 19, 2025
2 checks passed
@grdsdev grdsdev deleted the guilherme/use-url-api branch May 19, 2025 16:02
grdsdev added a commit that referenced this pull request May 20, 2025
* fix: merge global passed headers with default headers

* refactor: use URL type for manipulating urls

* use baeUrl directly

* use href
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants