You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Is your feature request related to a problem? Please describe.
We want to use URL to manage the configuration for our connection to an http based database. In our configuration we want to be able to separately specify host, port, user, password. Some of the code is old, and it takes the URL and appends ':' and the configured port. This works fine as long as we keep the URL without a terminating '/' but the URL object does not support this. When a URL is constructed without a '/' and then exported again using url.href the '/' is always appended. You cannot correct the issue by using url.pathname = ''
URL works great and I do not want to change the above functionality, just understand the context to provide insight into my desired solution. I want to be able to take the URL object and scoop out of it the protocol, user, password, host, port. There is currently not a getter (for example base) that would enable me to scoop this out. Instead I must do the following
let stringUrl = url.protocol + '//' + url.username + ':' url.password + '@' + url.hostname + ":" + url.port;
This would work, assuming that there is a username, or password, or port. If there isn't then I have to put if checks around the : and @ etc. But that really is the job of URL.
Describe the solution you'd like
Please describe the desired behavior.
Instead of coding the above, I just want to scoop out everything but the path and beyond. Something like
const myURL = new URL("https://abc:xyz@example.org/p/a/t/h?query=string#hash");
console.log(url.base)
// Prints https://abc:xyz@example.org
Node.js is only an implementer of the WHATWG URL standard here, so changes like this need to be accepted in the upstream before it can be implemented in Node.js. Please open your feature request in https://github.com/whatwg/url/issues, thanks
Is your feature request related to a problem? Please describe.
We want to use URL to manage the configuration for our connection to an http based database. In our configuration we want to be able to separately specify host, port, user, password. Some of the code is old, and it takes the URL and appends ':' and the configured port. This works fine as long as we keep the URL without a terminating '/' but the URL object does not support this. When a URL is constructed without a '/' and then exported again using url.href the '/' is always appended. You cannot correct the issue by using
url.pathname = ''
URL works great and I do not want to change the above functionality, just understand the context to provide insight into my desired solution. I want to be able to take the URL object and scoop out of it the protocol, user, password, host, port. There is currently not a getter (for example base) that would enable me to scoop this out. Instead I must do the following
let stringUrl = url.protocol + '//' + url.username + ':' url.password + '@' + url.hostname + ":" + url.port;
This would work, assuming that there is a username, or password, or port. If there isn't then I have to put if checks around the
:
and@
etc. But that really is the job of URL.Describe the solution you'd like
Please describe the desired behavior.
Instead of coding the above, I just want to scoop out everything but the path and beyond. Something like
also
expose
auth
andpathabsolute
(https://url.spec.whatwg.org/#relative-url-with-fragment-string)Describe alternatives you've considered
Coding it myself is always an option, but I would rather leave URL to do the work.
Note documentation also mentions an
auth
which makes one think there is a getter for it, but there is not. See documentation containing auth:I suggest updating the documentation to:
The text was updated successfully, but these errors were encountered: