-
Notifications
You must be signed in to change notification settings - Fork 10.9k
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
[10.x] Accept minecraft
protocol in URL validation
#47770
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.
👎 We should not diverge from the Symfony list. If we need something adding, it should be added to Symfony first.
@GrahamCampbell From what I can tell, Symfony doesn't include this list as the protocols are user-defined (which is more flexible): https://github.com/symfony/symfony/blob/v6.3.1/src/Symfony/Component/Validator/Constraints/UrlValidator.php#L25 And the default protocols only contains |
Then we need a way to add protocols the application accepts, instead of adding protocols to laravel as we go. As it may very well be that I need it to be https, but some idiot passed Minecraft url and now my app breaks if I do not add a regex to validate it starts with http... As far as I can tell, the url validation is basically useless IMHO. |
As Taylor Otwell suggested, you can use
I agree with you, especially as many protocols in this list doesn't make sense. I would be happy to do a new PR for a different approach to solve this, I'm just not sure how to do it, as my last attempt (#47381) was closed. |
I think the best approach would be having a short list with the most commonly used protocols ex: http,https, ftp, ssh, mailto, tel, blob, etc. And a configuration for other accepted protocol at application level, similar to how you can configure default string size for migrations $default = Str::$defaultAcceptedProtocols;
Str::defaultAcceptedProtocols([...$default, 'minecraft']); And a optional argument on |
Still no. I think we need something that allows you to specify the protocols your application accepts for that specific field. I can't think of a common use case where an url can be any of those, as your application, frontend or backend, needs to be able to handle them. Most of the time you want to register the website of a user. The user wants a Minecraft url, he is probably not planning to allow mailto or tel there. Simply http/https would be a default situation. anything else is for specific use cases. |
@MrMicky-FR let's actually just revisit your original PR: #47381 Can you reopen it? |
Seems like I can’t reopen a PR that I haven’t closed myself |
This adds support for the
minecraft
protocol inStr::isUrl
and theurl
validation rule. This protocol is a valid URL protocol used by the Minecraft game to join a Minecraft server (same idea as thesteam
protocol, which is already in the list).I had submitted a PR to be able to specify new protocols without having to modify this insane protocols list (#47381) but unfortunately it was closed and my latest comment is still unanswered after one month 😕