From cc6e623413cb69c2fdd00f984ea90ae398898944 Mon Sep 17 00:00:00 2001 From: undefined Date: Fri, 21 May 2021 18:14:38 +0800 Subject: [PATCH] util: remove node_modules/ in errMsg --- packages/hydrooj/package.json | 4 ++-- packages/hydrooj/src/handler/notfound.ts | 8 ++++++-- packages/utils/lib/utils.ts | 2 ++ packages/utils/package.json | 2 +- 4 files changed, 11 insertions(+), 5 deletions(-) diff --git a/packages/hydrooj/package.json b/packages/hydrooj/package.json index fcd512750..d9520d6a5 100644 --- a/packages/hydrooj/package.json +++ b/packages/hydrooj/package.json @@ -1,6 +1,6 @@ { "name": "hydrooj", - "version": "2.26.22", + "version": "2.26.23", "bin": "bin/hydrooj.js", "main": "dist/loader.js", "typings": "dist/loader.d.ts", @@ -11,7 +11,7 @@ "node": ">=14" }, "dependencies": { - "@hydrooj/utils": "^1.0.16", + "@hydrooj/utils": "^1.0.17", "adm-zip": "^0.5.5", "ansi_up": "^5.0.1", "cookies": "^0.8.0", diff --git a/packages/hydrooj/src/handler/notfound.ts b/packages/hydrooj/src/handler/notfound.ts index ea6da1308..d94baa3c3 100644 --- a/packages/hydrooj/src/handler/notfound.ts +++ b/packages/hydrooj/src/handler/notfound.ts @@ -1,10 +1,14 @@ /* eslint-disable no-empty-function */ /* eslint-disable class-methods-use-this */ import { NotFoundError } from '../error'; -import { Route, Handler } from '../service/server'; +import { + Route, Handler, param, Types, +} from '../service/server'; class NotFoundHandler extends Handler { - prepare() { + @param('bsod', Types.Boolean) + prepare(domainId: string, bsod: boolean) { + if (bsod) throw new Error(this.request.path); throw new NotFoundError(this.request.path); } diff --git a/packages/utils/lib/utils.ts b/packages/utils/lib/utils.ts index 4d4b1be75..a66fb6d96 100644 --- a/packages/utils/lib/utils.ts +++ b/packages/utils/lib/utils.ts @@ -270,6 +270,8 @@ export function errorMessage(err: Error | string) { .replace(/\/.+\/@hydrooj\//g, '\\') .replace(/[A-Z]:\\.+\\hydrooj\\/g, 'hydrooj\\') .replace(/\/.+\/hydrooj\//g, 'hydrooj/') + .replace(/[A-Z]:\\.+\\node_modules\\/g, '') + .replace(/\/.+\/node_modules\//g, '') .replace(/\\/g, '/'); if (typeof err === 'string') return parsed; err.stack = parsed; diff --git a/packages/utils/package.json b/packages/utils/package.json index 239a8f944..73744ec68 100644 --- a/packages/utils/package.json +++ b/packages/utils/package.json @@ -1,6 +1,6 @@ { "name": "@hydrooj/utils", - "version": "1.0.16", + "version": "1.0.17", "description": "hydrooj utils", "main": "package.json", "repository": "https://github.com/hydro-dev/Hydro.git",