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

Drop special 'back' case from response.redirect? #904

Closed
ricordisamoa opened this issue Feb 19, 2017 · 6 comments
Closed

Drop special 'back' case from response.redirect? #904

ricordisamoa opened this issue Feb 19, 2017 · 6 comments

Comments

@ricordisamoa
Copy link

if ('back' == url) url = this.ctx.get('Referrer') || alt || '/';

expressjs/express#2692 is stuck. I thought, Koa is the future, so you may be more open to breaking changes. Sorry if I'm wrong.

@PlasmaPower
Copy link
Contributor

Maybe just deprecate it for now? Koa v2 is pretty far into its final stages.

@tj
Copy link
Member

tj commented Feb 19, 2017

"only aims to save keystrokes" isn't that what programming is? Every line of code is aimed at hiding some logic to save writing it later. I'm not against removing it since it is kind of magical, but it wouldn't be too hard to say that about most getters/setters/functions/*.

@PlasmaPower
Copy link
Contributor

I don't like it because I often use redirections like ctx.redirect('edit') if the user is at /example-page/view. I could easily see ctx.redirect('back') causing a lot of confusion.

@ricordisamoa
Copy link
Author

For every keystroke saved by the 'magical' case, another keystroke is wasted debugging the inconsistency 😉 but what I really care about is that the issue gets settled once and for all, one way or the other.

@jonathanong
Copy link
Member

if anything, I would prefer this to be a symbol. const BACK = koa.BACK where BACK = Symbol('BACK')

@JeffRMoore
Copy link
Contributor

Since Symbol('BACK') !== 'BACK', it is a BC break anyway, right?

How about redirectBack()?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants