koa 2.16.1 → 2.16.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/response.js +15 -1
- package/package.json +12 -9
package/lib/response.js
CHANGED
|
@@ -240,6 +240,17 @@ module.exports = {
|
|
|
240
240
|
vary(this.res, field);
|
|
241
241
|
},
|
|
242
242
|
|
|
243
|
+
_getBackReferrer() {
|
|
244
|
+
const referrer = this.ctx.get('Referrer');
|
|
245
|
+
if (referrer) {
|
|
246
|
+
// referrer is an absolute URL, check if it's the same origin
|
|
247
|
+
const url = new URL(referrer, this.ctx.href);
|
|
248
|
+
if (url.host === this.ctx.host) {
|
|
249
|
+
return referrer;
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
},
|
|
253
|
+
|
|
243
254
|
/**
|
|
244
255
|
* Perform a 302 redirect to `url`.
|
|
245
256
|
*
|
|
@@ -261,7 +272,10 @@ module.exports = {
|
|
|
261
272
|
|
|
262
273
|
redirect(url, alt) {
|
|
263
274
|
// location
|
|
264
|
-
if ('back' === url)
|
|
275
|
+
if ('back' === url) {
|
|
276
|
+
url = this._getBackReferrer() || alt || '/';
|
|
277
|
+
}
|
|
278
|
+
|
|
265
279
|
if (/^https?:\/\//i.test(url)) {
|
|
266
280
|
// formatting url again avoid security escapes
|
|
267
281
|
url = new URL(url).toString();
|
package/package.json
CHANGED
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "koa",
|
|
3
|
-
"version": "2.16.
|
|
3
|
+
"version": "2.16.3",
|
|
4
|
+
"publishConfig": {
|
|
5
|
+
"access": "public",
|
|
6
|
+
"tag": "latest-2"
|
|
7
|
+
},
|
|
4
8
|
"description": "Koa web app framework",
|
|
5
9
|
"main": "lib/application.js",
|
|
6
10
|
"exports": {
|
|
@@ -21,13 +25,6 @@
|
|
|
21
25
|
"./package": "./package.json",
|
|
22
26
|
"./package.json": "./package.json"
|
|
23
27
|
},
|
|
24
|
-
"scripts": {
|
|
25
|
-
"test": "jest --forceExit",
|
|
26
|
-
"lint": "eslint --ignore-path .gitignore .",
|
|
27
|
-
"authors": "git log --format='%aN <%aE>' | sort -u > AUTHORS",
|
|
28
|
-
"build": "gen-esm-wrapper . ./dist/koa.mjs",
|
|
29
|
-
"prepare": "npm run build"
|
|
30
|
-
},
|
|
31
28
|
"repository": "koajs/koa",
|
|
32
29
|
"keywords": [
|
|
33
30
|
"web",
|
|
@@ -85,5 +82,11 @@
|
|
|
85
82
|
],
|
|
86
83
|
"jest": {
|
|
87
84
|
"testEnvironment": "node"
|
|
85
|
+
},
|
|
86
|
+
"scripts": {
|
|
87
|
+
"test": "jest --forceExit",
|
|
88
|
+
"lint": "eslint --ignore-path .gitignore .",
|
|
89
|
+
"authors": "git log --format='%aN <%aE>' | sort -u > AUTHORS",
|
|
90
|
+
"build": "gen-esm-wrapper . ./dist/koa.mjs"
|
|
88
91
|
}
|
|
89
|
-
}
|
|
92
|
+
}
|