Skip to content
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: trim trailing slash from custom rpc url #58

Merged

Conversation

vacekj
Copy link
Member

@vacekj vacekj commented Jun 25, 2024

Fixes edge case where entering a custom RPC URL with a trailing slash will result in links in other parts of the app being broken.

@grod220 I couldn't find a corresponding test file for this form - should I create one?

@vacekj vacekj linked an issue Jun 25, 2024 that may be closed by this pull request
Copy link

changeset-bot bot commented Jun 25, 2024

⚠️ No Changeset found

Latest commit: 4f437a7

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@vacekj vacekj requested a review from grod220 June 25, 2024 18:24
@turbocrime
Copy link
Contributor

turbocrime commented Jun 25, 2024

thanks!

i think instead of manipulating the input with a regex, which is unreliable and may be confusing to a user attempting to type in the input, we should use the browser's validation tools before testing and saving the url.

on my phone at the moment, but something like new URL(grpcEndpointInput).href at the appropriate locations should generate a canonical format, and provide comprehensive validation and formatting.

additionally, we should look for code that concatenates URLs as strings, instead of using these tools which also provide correct path joining. this would be the true source of the double slash.

@vacekj
Copy link
Member Author

vacekj commented Jun 26, 2024

Agree.

the input is already marked as type="url", so that provides enough validation imo. In terms of joining the URL, we can indeed use the URL constructor:

new URL('/one', 'http://example.com/').href

which works with or without a trailing slash.

@vacekj vacekj force-pushed the 52-rpc-url-trailing-slash-isnt-trimmed-during-onboarding branch from 4b17f04 to 66f334e Compare June 27, 2024 07:58
@vacekj vacekj marked this pull request as ready for review June 27, 2024 15:32
@vacekj vacekj force-pushed the 52-rpc-url-trailing-slash-isnt-trimmed-during-onboarding branch from 25dcc8c to 4f437a7 Compare July 1, 2024 11:20
@vacekj
Copy link
Member Author

vacekj commented Jul 1, 2024

@turbocrime requesting re-review, lmk if there's anything else I should change. @prax-wallet/web-reviewers also, thanks!

Copy link
Contributor

@turbocrime turbocrime left a comment

Choose a reason for hiding this comment

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

looks good to me

@vacekj vacekj merged commit d28a16d into main Jul 2, 2024
3 checks passed
@vacekj vacekj deleted the 52-rpc-url-trailing-slash-isnt-trimmed-during-onboarding branch July 2, 2024 20:06
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.

RPC URL trailing slash isn't trimmed during onboarding
2 participants