Skip to content
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

Follow redirects with encoded URI #564

Merged
merged 5 commits into from Aug 23, 2018

Conversation

jstewmon
Copy link
Contributor

@jstewmon jstewmon commented Aug 15, 2018

Fixes #563

- add arguments test for query with special chars
- add redirects test for uri-encoded location with special chars
- redirects are handled with a recursive call to `get`, so deferred
  recursion with setImmediate
- test server enhancement:
  - now replies with 404 if no listener
  - decodes request.url before emission
@jstewmon jstewmon changed the title chore: add test for query with special chars fix: follow redirects with encoded URI Aug 15, 2018
@szmarczak
Copy link
Collaborator

szmarczak commented Aug 22, 2018

@sindresorhus IMO it's ready to merge.

https://github.com/sindresorhus/got/pull/564/files#diff-62bdc57f6f22ae58f495daef16f21f8bR93 is not needed, because the function is called when http.request emits the response.

@@ -74,7 +74,7 @@ module.exports = options => {
redirectUrl = (new URLGlobal(bufferString, urlLib.format(options))).toString();
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think using urlLib.format to get the baseUrl has the same problem as was discussed in #519 (comment).

I can take a look at adding a test and fixing today.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The baseUrl won’t have the right query string, but I don’t think there’s any value for new url for which it would affect the result. So this seems fine.

@szmarczak
Copy link
Collaborator

redirects are handled with a recursive call to get, so deferred
recursion with setImmediate

See my comment above.

test server enhancement:

Could this be placed in a separate PR please?

@sindresorhus sindresorhus changed the title fix: follow redirects with encoded URI Follow redirects with encoded URI Aug 23, 2018
@sindresorhus
Copy link
Owner

sindresorhus commented Aug 23, 2018

redirects are handled with a recursive call to get, so deferred
recursion with setImmediate

See my comment above.

I've reverted this: 731c470

test server enhancement:

Could this be placed in a separate PR please?

I agree this should have been a separate change, but we decided we can live with it as we want to get out a new minor release today, and it's just nitpick.

@sindresorhus sindresorhus merged commit 3d98b9b into sindresorhus:master Aug 23, 2018
@sindresorhus
Copy link
Owner

Thanks for fixing this, @jstewmon 🙌

@jstewmon jstewmon deleted the query-escapes branch August 24, 2018 17:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants