silverstripe / silverstripe-framework

Silverstripe Framework, the MVC framework that powers Silverstripe CMS
https://www.silverstripe.org
BSD 3-Clause "New" or "Revised" License
719 stars 820 forks source link

NEW Add UrlField #11116

Closed emteknetnz closed 5 months ago

emteknetnz commented 5 months ago

Issue https://github.com/silverstripe/silverstripe-linkfield/issues/17

emteknetnz commented 5 months ago

@GuySartorelli Since parse_url() doesn't actually validate the url, and symfony/validator was just weird (uses attributes) I've switched back to using filter_var() for the actual validation. It works fine, unit tests pass which include underscores and parenthesis in tests

GuySartorelli commented 5 months ago

Assuming you approve and merge https://github.com/silverstripe/silverstripe-framework/pull/11123, please use symfony/validator for validating the URL.

michalkleiner commented 5 months ago

Good addition. Have you thought about supporting other URI schemas, not just http(s)?

There are other schemas such as mailto, tel, sftp, git+ssh, protocol-less URLs are also valid starting with //, so I think this is currently underdelivering and if people wanted to use it for other URLs than just web URLs then they would need to resort to plain text fields again and won't benefit from the new field.

For reference e.g. https://en.wikipedia.org/wiki/List_of_URI_schemes and https://en.wikipedia.org/wiki/Uniform_Resource_Identifier#Example_URIs.