-
Notifications
You must be signed in to change notification settings - Fork 37
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
.asUrlString() attaches "/" to url #126
Comments
Internally Here's an example from Node.js v14.3.0. new URL('http://a.b.com').toString()
'http://a.b.com/'
new URL('http://a.b.com/hello').toString()
'http://a.b.com/hello' I feel like it makes sense to add the trailing slash, since in reality you're making a request to |
Probably worth mentioning. I spent a couple of minutes trying to understand why my request is failing. |
@nirsky gotcha, I think a PR in docs reminding developers to use the URL module/class when working with URLs is a good idea, e.g instead of: var path = '/thing'
var baseUrl = env.get('MY_URL').asUrlString()
// Could create invalid URL with two slashes!
var fullUrl = baseUrl + path doing this: var path = '/thing'
var baseUrl = env.get('MY_URL').asUrlString()
// Will be correct, with no double forward slashes
var fullUrl = new URL(path, baseUrl).toString() Would you like to PR it? |
@nirsky this will be addressed in docs in 6.2.0 |
Hey,
As the title says.
Not sure if this by design or a bug, but I think it's very confusing.
example:
The text was updated successfully, but these errors were encountered: