-
Notifications
You must be signed in to change notification settings - Fork 3.2k
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
Feature/base url #1469
Feature/base url #1469
Conversation
Regarding this one #1464 @froatsnook I think you are overthinking it.
How that sounds? I understand your point of view to make everything bulletproof but is it logical in the first place? You are clearly stating what is the expected behavior in the README (the example), the rest of the code is just trying to prevent some potential bugs introduced by the user, that might happen :) |
That sounds much easier. Should I squash everything to one commit? Also, should baseUrl in README be lower since it's not as important as some of the first parameters? |
Yes, some of the previous commits will become obsolete in this case 👍 As for the README I think this place is fine, as it is related to the |
574288d
to
d13ccd2
Compare
Good job @froatsnook I really like how tight and clean the implementation is looking. Also I really do like the new naming of the test cases, the previous ones were a bit odd :) A couple of notes:
I just noticed that the tests are throwing some errors when executed via ./node_modules/.bin/istanbul cover ./node_modules/tape/bin/tape tests/test-*.js on your localhost and navigate to |
Thanks @simov, done and done :). I think I thought test names had to be camelCase from glancing at test-body.js... well that's my story and I'm sticking to it! Thanks for the tip on code coverage. That's really useful. |
Looking good to me, lets see if anyone else have something to add, otherwise I'll merge it. |
Hey Im looking over this feature today, can you give me a little time to give feedback before merging? |
Sure 👍 |
The docs should have some examples of how this works. I also don't think we should enforce that this should give me an error. request('/home', {baseUrl: 'http://localhost:8080'}, function(err, res, body) {
}) I would expect this to make a request to |
We also should probably just give an error if we see a path with request('//home', {baseUrl: 'http://localhost:8080'}, function(err, res, body) {
}) Would give an error. That's because |
Example would be good, also |
@seanstrom In the current version that case is covered since an error is thrown when the |
@seanstrom @simov But maybe it's a lot less confusing if paths like that are just treated as relative paths and concatenated so that |
The example in your last comment is incorrect, although that's the idea exactly. |
In other words both |
@simov OK I definitely agree that it's better like that. Will update. |
@froatsnook in your first example you used: |
Also the tests themselves should test that it gets the correct error. Currently it just checks that it's not |
} | ||
|
||
if (typeof self.uri !== 'string') { | ||
return self.emit('error', new Error('options.uri must be a string when using options.baseUrl')) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we probably should say that "uri must be a string" instead of "options.uri", since we can just pass the uri value directly.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
actually disregard this comment. Seems like we use this verbiage elsewhere
Okay im pretty with this, thanks for all the good work @froatsnook 👍 |
I'm fine with it too, lets see how it goes for a while, I might use this option in some of my projects as well. @froatsnook you can specify which issues you are closing or fixing in your PR's description (see above).
That way the corresponding issues will be closed automatically once this PR got merged in. You can specify such things in the commit messages as well, but that can get a bit annoying sometimes :) 👍 |
@seanstrom Thanks for all the suggestions and the kind words. @simov Thanks for the info. |
Great work guys |
This pull request contains bug when working with redirections. Details in my pull request #1481 . |
Closes #1464
Closes #1476
Some remaining questions: