vona-core 5.1.38 → 5.1.40
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/dist/index.js +7 -4
- package/dist/index.js.map +1 -1
- package/dist/lib/core/context.d.ts.map +1 -1
- package/dist/lib/utils/util.d.ts.map +1 -1
- package/dist/types/context/contextBase.d.ts +5 -0
- package/dist/types/context/contextBase.d.ts.map +1 -1
- package/dist/types/context/index.d.ts +1 -0
- package/dist/types/context/index.d.ts.map +1 -1
- package/package.json +2 -2
- package/src/lib/core/context.ts +6 -5
- package/src/lib/utils/util.ts +1 -0
- package/src/types/context/contextBase.ts +6 -0
- package/src/types/context/index.ts +1 -0
package/dist/index.js
CHANGED
|
@@ -306,6 +306,7 @@ class AppUtil extends BeanSimple {
|
|
|
306
306
|
createError(data, returnObject) {
|
|
307
307
|
const error = returnObject ? {} : new Error();
|
|
308
308
|
error.code = data.code !== undefined ? data.code : 500;
|
|
309
|
+
if (data.status !== undefined) error.status = data.status;
|
|
309
310
|
if (data.message && typeof data.message === 'object') {
|
|
310
311
|
error.message = JSON.stringify(data.message, null, 2);
|
|
311
312
|
} else {
|
|
@@ -2286,16 +2287,18 @@ const contextBase = {
|
|
|
2286
2287
|
if (self.accepts('html', 'text', 'json') === 'json') return true;
|
|
2287
2288
|
return false;
|
|
2288
2289
|
},
|
|
2289
|
-
redirect(url,
|
|
2290
|
+
redirect(url, statusOrOptions) {
|
|
2290
2291
|
const self = cast(this);
|
|
2292
|
+
const options = typeof statusOrOptions === 'number' ? {
|
|
2293
|
+
status: statusOrOptions
|
|
2294
|
+
} : statusOrOptions ?? {};
|
|
2291
2295
|
// checkOrigin
|
|
2292
|
-
if (!url.startsWith('/')) {
|
|
2296
|
+
if (!url.startsWith('/') && !options.trustedExternal) {
|
|
2293
2297
|
const origin = cast(self.app.bean).security.checkOrigin(url, self.host);
|
|
2294
2298
|
if (!origin) self.app.throw(403);
|
|
2295
2299
|
}
|
|
2296
2300
|
// throw
|
|
2297
|
-
status
|
|
2298
|
-
self.app.throw(status, url);
|
|
2301
|
+
self.app.throw(options.status ?? 302, url);
|
|
2299
2302
|
}
|
|
2300
2303
|
};
|
|
2301
2304
|
|