Skip to content

Conversation

grdsdev
Copy link
Contributor

@grdsdev grdsdev commented Jul 31, 2025

What kind of change does this PR introduce?

Fix/Improvement

Additional context

Reference PR

Copy link
Contributor

@Copilot 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

This PR introduces a dedicated storage host feature for the Supabase Storage client. The change allows the client to automatically replace legacy Supabase URLs with new storage-specific URLs to improve upload performance for large files.

  • Adds a new useNewHostname configuration option to enable automatic URL transformation
  • Implements URL transformation logic to replace legacy hosts with dedicated storage hosts
  • Updates the client configuration flow to support the new option

Reviewed Changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
Sources/Supabase/Types.swift Adds StorageOptions struct with useNewHostname configuration
Sources/Supabase/SupabaseClient.swift Passes storage options to the storage client configuration
Sources/Storage/SupabaseStorage.swift Updates StorageClientConfiguration to include useNewHostname parameter
Sources/Storage/StorageApi.swift Implements URL transformation logic for dedicated storage hosts
Tests/StorageTests/StorageBucketAPITests.swift Adds comprehensive test coverage for URL transformation behavior

// "project-ref.supabase.co" becomes "project-ref.storage.supabase.co"
if configuration.useNewHostname == true {
var components = URLComponents(url: configuration.url, resolvingAgainstBaseURL: false)!
let regex = try! NSRegularExpression(pattern: "supabase.(co|in|red)$")
Copy link
Preview

Copilot AI Jul 31, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using 'try!' for regex compilation is risky. Consider using 'try?' or proper error handling since invalid regex patterns would crash the application.

Suggested change
let regex = try! NSRegularExpression(pattern: "supabase.(co|in|red)$")
guard let regex = try? NSRegularExpression(pattern: "supabase.(co|in|red)$") else {
fatalError("Invalid regex pattern: supabase.(co|in|red)$")
}

Copilot uses AI. Check for mistakes.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

force unwrapping is fine since we're providing pattern statically, which is guaranteed to work.

@grdsdev grdsdev merged commit 9272f1e into main Aug 1, 2025
17 checks passed
@grdsdev grdsdev deleted the guilherme/clibs-229-supabase-swift-use-dedicated-storage-host-for-storage-lib branch August 1, 2025 15:35
@supabase-releaser
Copy link

🎉 This PR is included in version 2.31.1 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants