Skip to content

fix: guard isGravatarUrl against invalid URL strings#4034

Open
adids1221 wants to merge 1 commit into
masterfrom
fix-avatar-helper-invalid-url
Open

fix: guard isGravatarUrl against invalid URL strings#4034
adids1221 wants to merge 1 commit into
masterfrom
fix-avatar-helper-invalid-url

Conversation

@adids1221

Copy link
Copy Markdown
Contributor

Description

PR #4033 replaced url-parse with the native URL API in AvatarHelper. However, the native URL constructor throws a TypeError when given an invalid URL string (e.g. 'fakeUrl', ''), unlike url-parse which was lenient.

This caused headless test failures in wix-react-native-ui-lib when Avatar components received non-URL strings as the image source — isGravatarUrl would throw instead of returning false.

The fix wraps new URL(url) in a try/catch inside isGravatarUrl and returns false for any input that isn't a valid URL.

Changelog

AvatarHelperisGravatarUrl now returns false for invalid URL strings instead of throwing.

Additional info

Fixes the regression introduced by #4033. Caught by headless tests in wix-react-native-ui-lib where Avatar receives arbitrary strings as image URIs.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@github-actions

Copy link
Copy Markdown
Contributor

✅ PR Description Validation Passed

All required sections are properly filled out:

  • Description
  • Changelog
  • Additional info

Your PR is good for review! 🚀


This validation ensures all sections from the PR template are properly filled.

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.

1 participant