myscheme:?id=test
If I pass this to [NSURL URLWithString:]
and print its query
property, I get nil
, but if I put a slash right after the colon (or two or three) it works fine.
Is this actually an invalid URL or is it a bug in NSURL
?
According to some research, it appears to be a valid URL. From http://url.spec.whatwg.org/:
An absolute URL must be a scheme, followed by ":", followed by scheme data, optionally followed by "?" and a query.
and (emphasis added)
The syntax of scheme data depends on the scheme and is typically defined alongside it. For a relative scheme, scheme data must be a scheme-relative URL. For other schemes, specifications or standards must define scheme data within the constraints of zero or more URL units.