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

improve url validation in settings #173

Merged
merged 2 commits into from
May 14, 2023
Merged

improve url validation in settings #173

merged 2 commits into from
May 14, 2023

Conversation

jcalado
Copy link
Contributor

@jcalado jcalado commented May 12, 2023

It doesn't look to me like URI.tryParse is doing enough to verify if a URL is ok.
It might be better to just check against a regex like https?:\/\/

Copy link
Owner

@austinried austinried left a comment

Choose a reason for hiding this comment

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

The problem with bypassing the Uri.tryParse() check is going to be further down the line when Uri.parse() is used, since the HttpClient relies on a valid Uri for requests.

Can you give some specific examples of URLs that don't pass here but should work?

@jcalado
Copy link
Contributor Author

jcalado commented May 13, 2023 via email

@austinried
Copy link
Owner

Ah yeah, I see now that's actually passing the Uri.tryParse() but not working later with the HTTP client in those cases. In 1.x this is solved by adding the scheme to the URL if it's missing, I think we could do something similar here by try/catching Uri.parse() and checking the scheme, then prepending a default if it's missing.

@austinried
Copy link
Owner

Actually thinking about this more, even without automatically adding the scheme this does seem like an improvement on the existing validation so we can merge it in.

@austinried
Copy link
Owner

Looks good, thank you!

@austinried austinried merged commit 889be2f into austinried:main May 14, 2023
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.

2 participants