-
-
Notifications
You must be signed in to change notification settings - Fork 450
fix: add validation for supabaseUrl #1547
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
Hi there @maxmetcalfe! Thank you so much for this PR! Adding URL validation is a great security improvement that will help prevent accidental credential exposure (as mentioned in #1239). Really appreciate you taking the initiative on this. The implementation looks solid! I have a few small suggestions that would make it even more robust: Suggested improvements:
export function validateSupabaseUrl(supabaseUrl: string): URL {
const trimmedUrl = supabaseUrl?.trim()
if (!trimmedUrl) {
throw new Error('supabaseUrl is required.')
}
// ... rest of validation
}
if (!trimmedUrl.match(/^https?:\/\//i)) {
throw new Error('Invalid supabaseUrl: Must be a valid HTTP or HTTPS URL.')
}
// Test with leading/trailing whitespace
expect(() => createClient(' https://xyz123.supabase.co ', KEY)).not.toThrow()
// Test with URL containing auth (should work but might want to warn in future)
expect(() => createClient('http://user:pass@localhost:54321', KEY)).not.toThrow() These are all minor suggestions, the core functionality is great as-is! Thanks again for your work on this! 🙏 |
Pull Request Test Coverage Report for Build 17568478925Warning: This coverage report may be inaccurate.This pull request's base commit is no longer the HEAD commit of its target branch. This means it includes changes from outside the original pull request, including, potentially, unrelated coverage changes.
Details
💛 - Coveralls |
thanks @mandarini, updated! |
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.
Thank you @maxmetcalfe !
What kind of change does this PR introduce?
This PR adds basic url validation for the supaseUrl.
What is the current behavior?
The client does not validate the supaseUrl (besides requiring it)
What is the new behavior?
The client runs simple validation on the supaseUrl.
Additional context
This will improve the experience for new Supabase users as well as help prevent the leaking of credentials to stdout/sterr (see: #1239).