Replies: 1 comment 4 replies
-
The request may not have a Host header so I don't think it's feasible for http.Server to pre-construct an URL object. |
Beta Was this translation helpful? Give feedback.
4 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I'm putting this a discussion, since as feature request I don't have an idea how to solve it:
Back in the old days things were clear, in the handler to http(s) request one would write:
and then use "red" to deteremine what to serve. Was always okay to me.
But url.parse is depcrecated and WHATWG URL should be used.
But now this becomes for example:
But honestly, why do I now need to build an URL just to parse it again?
Why is "request.url" not an url, but a pathname? IMO this was a pretty awkward idea to put a pathname and call it "url". I know its been like this since 0.1 and probably due to backwards compatiblity never changed.. but you must admit, its really awkward, isn't it?
Or the docs say as an example:
Which also makes http as protocol, albeit it was https.
In a better world request.url should IMO already an URL object. If not could we consider to make a getter for say request.URL (in captial letters) to be an URL object provided by the core?
Beta Was this translation helpful? Give feedback.
All reactions