expressjs.com
expressjs.com copied to clipboard
Add to docs information on routing URLs
So there was the issue https://github.com/expressjs/express/issues/3088 filed in Express recently regarding confusion about how Express handles routing when the incoming URL is a full URL instead of just the path (i.e. GET http://localhost/ HTTP/1.1
vs GET / HTTP/1.1
). I browsed around through the docs and it doesn't seem super clear.
I can see two possible ways to enhance the documentation around this:
- In the routing section, we can probably call out that the
path
argument matches only against thepathname
part of the request URL and nothing else. This is an indirect answer to a lot of the matching questions like the above as well as calling out that no, it does not match against the query part, host part, etc. - If we want to, we can explicitly call out that any scheme, auth, host, querystring, etc. in the request URL are ignored during the routing. Perhaps we can show an example of
http://localhost/foo?bar=1
only routing against the/foo
part.
Anyway, those are some of my initial thoughts on the docs from that issue :)
I agree that we need to clarify this in the docs. I can see how it would (did?) lead to some confusion. So your two suggestions @dougwilson seem like a really good place to start.