-
-
Notifications
You must be signed in to change notification settings - Fork 173
fix(storage): use dedicated storage host #761
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
fix(storage): use dedicated storage host #761
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
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 |
Sources/Storage/StorageApi.swift
Outdated
// "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)$") |
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.
Using 'try!' for regex compilation is risky. Consider using 'try?' or proper error handling since invalid regex patterns would crash the application.
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.
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.
force unwrapping is fine since we're providing pattern statically, which is guaranteed to work.
Co-authored-by: Copilot <[email protected]>
Co-authored-by: Copilot <[email protected]>
🎉 This PR is included in version 2.31.1 🎉 The release is available on GitHub release Your semantic-release bot 📦🚀 |
What kind of change does this PR introduce?
Fix/Improvement
Additional context
Reference PR