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

fix: hardcoded redirection http status #608

Merged
merged 8 commits into from
Feb 16, 2022

Conversation

crookse
Copy link
Member

@crookse crookse commented Feb 15, 2022

Closes #607

Summary

  • Remove hard-coded 302 in resource.redirect() method
  • Allow status and headers to be specified in resource.redirect() (just like the response class' methods)
    • status can only be of type HttpStatusRedirection which ranges from 300 - 308 (excluding 306 since it's not a used status)

Other Notes

  • We should deprecate the resource.redirect() method in favor of response.redirect() since response.redirect() is the native way to do it based on MDN docs. I didn't know response.redirect() existed, so my bad on opting for resource.redirect()

…ers to be specified for .redirect()

Trying to make this more like the response class' body methods.
@crookse crookse added the Type: Patch Merging this pull request results in a patch version increment label Feb 15, 2022
Copy link
Member

@ebebbington ebebbington left a comment

Choose a reason for hiding this comment

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

My bad lol

src/types.ts Outdated
Comment on lines 27 to 35
export type HttpStatusRedirection =
| 300
| 301
| 302
| 303
| 304
| 305
| 307
| 308;
Copy link
Member

Choose a reason for hiding this comment

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

Question about this. I know that 3xx are the redirect status codes, but do you think we should be so strict about the status codes? Maybe someone wants to mask the url and not give a 3xx status code. I'm not sure...

Copy link
Member Author

Choose a reason for hiding this comment

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

i see. yea maybe we shouldn't be strict in this regard. i don't know if a use case outside of 3xx, but maybe there is one

Copy link
Member

Choose a reason for hiding this comment

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

Yes, my question is exactly that... Don't know if it's a valid thing or not. I'm for the restriction of 3xx, but I'm not sure if there's a use case.

Copy link
Member Author

Choose a reason for hiding this comment

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

@crookse crookse merged commit 646e19e into main Feb 16, 2022
@crookse crookse deleted the fix/hardcoded-redirection-http-status branch February 16, 2022 02:48
This pull request was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Type: Patch Merging this pull request results in a patch version increment
Development

Successfully merging this pull request may close these issues.

fix: hard-coded redirection http status on resource.redirect()
3 participants