Tima
Tima

Reputation: 12905

java.net.URL/URI consider an invalid URL as valid

Not all invalid urls will be consider as invalid by java.net.URL/URI

An example: http:www.google.com

Is it a bug or is it a feature?

Or is maybe the string above a valid url?

Upvotes: 1

Views: 542

Answers (1)

Andreas
Andreas

Reputation: 159086

Without //, the URL is treated as a relative URL, that needs a context to be useful.

If you try using it, you'll get this error:

IllegalArgumentException: protocol = http host = null

Upvotes: 2

Related Questions