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

Allow dynamically set followRedirect #2307

Closed
1 task done
VanTigranyan opened this issue Oct 27, 2023 · 1 comment
Closed
1 task done

Allow dynamically set followRedirect #2307

VanTigranyan opened this issue Oct 27, 2023 · 1 comment

Comments

@VanTigranyan
Copy link
Contributor

What problem are you trying to solve?

Request library allows passing followRedirect as a function that gets the intermediate response and then returns boolean, by which the library decides whether to follow the redirect. Got doesn't allow this. As a workaround, I tried to change options.followRedirect to false in beforeRedirect hook, but that doesn't work as one would expect.

Describe the feature

Allow both plain boolean and function type for the followRedirect option.
I already made proper changes in the code and in README and added tests to make sure all works correctly.
#2306
...

  const {statusCode} = await got('temporary', {followRedirect(response) {
        t.is(response.headers.location, '/redirect');
        return false;
  }});

Checklist

  • I have read the documentation and made sure this feature doesn't already exist.
@sindresorhus
Copy link
Owner

Fixed by 7c3f147

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

No branches or pull requests

2 participants