Today we had an arguing with colleague about if that would be a valid URL http://domain.com?some_param=1
. The RFC that defines URL structure does not explicitly states that that is invalid structure. According to RFC 1738, part 3.3
If neither <path> nor <searchpart> is present, the "/" may also be omitted.
However, at the end of part 3.1 of same document it says
Note that the "/" between the host (or port) and the url-path is NOT part of the url-path.
Checking up with curl revealed some interesting thing
$ curl -v -I http://stackoverflow.com?test
* Rebuilt URL to: http://stackoverflow.com/?test
...
So, question is
Is this is a valid URL or not? http://domain.com?some_param=1
Section 3.3 defers to section 3.1 for host
and port
, but the rest is as defined in that section. Thus, the slash after port
is required if either of path
or searchpart
is present.
Nonetheless tools may attempt to extract a valid URL even with the omission of this slash, since one of the precepts of various ideologies is to be liberal on input and conservative on output.