koajs / koa

Expressive middleware for node.js using ES2017 async functions
https://koajs.com
MIT License
35.23k stars 3.23k forks source link

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

Closed ricordisamoa closed 3 weeks ago

ricordisamoa commented 7 years ago

https://github.com/koajs/koa/blob/18dbf5f59c9f3e487e2b49c6dac483d1bed88974/lib/response.js#L254

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 commented 7 years ago

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

tj commented 7 years ago

"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 commented 7 years ago

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 commented 7 years ago

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

jonathanong commented 7 years ago

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

JeffRMoore commented 7 years ago

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

How about redirectBack()?