I'm trying to detect whether url is valid for using in WebView
or not. There is an address bar in my WebView
, so users can choose to navigate to another site or using keyword for search in google engine.
The problem is that all the solutions that I've found don't work properly. Cause if url is set without http, and I added it automatically, so it can considered valid url although it doesn't have any suffix.
Examples:
http://www.google.com - RETURN TRUE
google.com - RETURN TRUE (http will be added automatically)
http://google - RETURN FALSE (many validators consider this TRUE)
www.google - RETURN FALSE
So, what I'm trying to get is validator that verify string has the url structure, and if http is missing just add it. But if the string is not in url structure - go to another path (google engine for this example).
Thanks a lot.