Reputation: 4476
Why Grails see URLs without http:// (like www.google.com) as invalid? Only http://google.com and http://www.google.com are ok. Is there any way to fix that ?
Upvotes: 0
Views: 1099
Reputation: 5198
If you read RFC 1738 (Uniform Resource Locators), it is clear that the URL scheme (in your case, http://), is a full part of URLs. The scheme defines the meaning of the rest of the URL, and thus, can't be omitted. For instance http://www.google.com is definitely not the same ressource as https://www.google.com, and you should be aware of that when you save a link.
So URL like www.google.com
are not valid, and Grails is right when it rejects them.
Fixing that should be easy if you know you expect an http URL:
new Object(url: 'http://' + url).save()
should do the trick.
Upvotes: 3