A better URL::isWellFormed()

URL::isWellFormed() only checks if the url isn’t empty at the moment.

could it at least checks also that the url doesn’t contain spaces or other forbidden characters?

any chance this gets improved at some point?
It’s been 18years (no joke) that the implementation is marked ‘todo’ :slight_smile:

bool URL::isWellFormed() const
{
    //xxx TODO
    return url.isNotEmpty();
}

I had a sneaking suspicion that URLs are as rule-less as email addresses, but it looks like there are at elast some standards that could be followed:

Whether or not that’s suitable to use in a cross-platform framework, idk - I wouldn’t be surprised if different platforms/browsers/etc. have different rules. E.g. you say a URL shouldn’t have spaces, but URLs can point to files which on most OSs can have spaces in the name.

This regex seems to do a good job of validating website URLs: RegExr: Learn, Build, & Test RegEx - maybe a more generic one is needed for file URLs?

They’re not, URIs are very well defined, and most modern languages have standards-compliant ways of dealing with them.

Operating systems/browsers/etc respect the rules for parsing them. It’s a trivial problem to solve. Representing a resource as a URI is slightly non trivial.

E.g. you say a URL shouldn’t have spaces, but URLs can point to files which on most OSs can have spaces in the name.

non-URI safe characters must be escaped in URIs.