Skip to content

response.redirect: extract special-cased back, fixes #904#1115

Merged
jonathanong merged 2 commits intokoajs:masterfrom
fl0w:refactor-back
Oct 20, 2024
Merged

response.redirect: extract special-cased back, fixes #904#1115
jonathanong merged 2 commits intokoajs:masterfrom
fl0w:refactor-back

Conversation

@fl0w
Copy link
Contributor

@fl0w fl0w commented Dec 27, 2017

The simple solution to drop special-cased 'back' in response.redirect.
I can't label but should be labeled as version-major.

This PR does not make use of Symbol as purposed in #904.

Edit
If this solution is acceptable, a deprecation should be added to Koa 2 on 'back' use.

@codecov
Copy link

codecov bot commented Dec 27, 2017

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 99.47%. Comparing base (b89e19a) to head (ad03d65).
Report is 18 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1115      +/-   ##
==========================================
- Coverage   99.61%   99.47%   -0.14%     
==========================================
  Files           5        7       +2     
  Lines         520      575      +55     
  Branches      147      165      +18     
==========================================
+ Hits          518      572      +54     
- Misses          2        3       +1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@fl0w
Copy link
Contributor Author

fl0w commented Dec 28, 2017

I'm assuming this is a travis-cache thingie that fails, can't reproduce it locally.

$ git rev-parse --abbrev-ref HEAD
refactor-back
$ node -v
v9.3.0
$ npm -v
5.6.0
$ npm view koa version
2.4.1
$ npm t

# abbreviated jest output

Test Suites: 66 passed, 66 total
Tests:       298 passed, 298 total
Snapshots:   0 total
Time:        2.265s
Ran all test suites.

@jonathanong
Copy link
Member

👍

let's add this as a feature + deprecation message, then a separate PR to remove it in the next major version

@fl0w
Copy link
Contributor Author

fl0w commented Feb 15, 2018

@jonathanong updated, and should be safe as a semver-minor merge. Just take a quick look at the deprecation message before doing so.

Copy link
Member

@3imed-jaberi 3imed-jaberi left a comment

Choose a reason for hiding this comment

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

LGTM, I believe that should be merged this PR 🚀

@kevinpeno kevinpeno force-pushed the refactor-back branch 2 times, most recently from a231946 to aa5f75b Compare October 20, 2024 22:54
@kevinpeno
Copy link
Contributor

@jonathanong should be gtg. Codecov is bitching, but the related missed line is not related to the changes made in this PR. It is likely the methods added to this PR pushed the file over its limits. I think we should ignore it for this PR.

@kevinpeno kevinpeno self-assigned this Oct 20, 2024
@jonathanong jonathanong merged commit f9f7714 into koajs:master Oct 20, 2024
@iwanofski
Copy link
Member

I couldn't see this update because this was done om my "stolen" account :) Great to see this merged.

titanism added a commit to forwardemail/forwardemail.net that referenced this pull request Jan 5, 2026
…oa v3

Koa v3 removes ctx.redirect('back') and replaces it with ctx.back(fallbackUrl).
This polyfill intercepts ctx.redirect('back') calls and converts them to use
the Referer header with a fallback URL, maintaining backward compatibility
with the 34 existing usages in the codebase.

- Add helpers/koa-redirect-back-polyfill.js middleware
- Apply polyfill to web, api, caldav, and carddav servers via hookBeforeSetup
- No changes needed to existing controller code
- Supports localized fallback URLs via ctx.state.l()

@see https://github.com/koajs/koa/releases/tag/v3.0.0
@see koajs/koa#1115
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants