Improve URL validation for product submission form
Closed this issue · 3 comments
Currently URL validation is taken care of by validate_url gem, which checks if URI scheme exists.
Entering "www.example.com" or "example.com" throws an exception, and the app returns an error message that is not very helpful - "is not a valid URL".
Solutions:
- Prepend URI scheme if it doesn't exist (match regex), before validates_url
- Configure a more helpful error message
- or other possible solutions
+1 💯
I'm not sure if you should allow blank URLs, since users of the site won't be able to able to read up or check out what the product actually does. May become frustrating if a considerable amount of products submitted do not have URLs.
Also, I've re-enabled the validates_url gem; configured a more friendly error message and added in a simple check if protocol exists.
We may need to validate if domain actually exists, since the URI parser Addressable::URI used in validates_url gem is very lenient. If I'm not wrong, white spaces will pass validation.
merged and fixed. thanks @edisonchee!!