From 31789495a203e6eac815964947985e6508173000 Mon Sep 17 00:00:00 2001 From: SleeplessOne1917 <abias1122@gmail.com> Date: Sun, 2 Jul 2023 15:45:45 -0400 Subject: [PATCH] Prevent JWT token from showing up on error page --- src/shared/components/app/error-page.tsx | 3 ++- src/shared/utils/helpers/remove-auth-param.ts | 6 ++++++ 2 files changed, 8 insertions(+), 1 deletion(-) create mode 100644 src/shared/utils/helpers/remove-auth-param.ts diff --git a/src/shared/components/app/error-page.tsx b/src/shared/components/app/error-page.tsx index ec352d4..996fcdb 100644 --- a/src/shared/components/app/error-page.tsx +++ b/src/shared/components/app/error-page.tsx @@ -1,4 +1,5 @@ import { setIsoData } from "@utils/app"; +import removeAuthParam from "@utils/helpers/remove-auth-param"; import { Component } from "inferno"; import { T } from "inferno-i18next-dess"; import { Link } from "inferno-router"; @@ -58,7 +59,7 @@ export class ErrorPage extends Component<any, any> { <T i18nKey="error_code_message" parent="p" - interpolation={{ error: errorPageData.error }} + interpolation={{ error: removeAuthParam(errorPageData.error) }} > #<strong className="text-danger">#</strong># </T> diff --git a/src/shared/utils/helpers/remove-auth-param.ts b/src/shared/utils/helpers/remove-auth-param.ts new file mode 100644 index 0000000..0702b10 --- /dev/null +++ b/src/shared/utils/helpers/remove-auth-param.ts @@ -0,0 +1,6 @@ +export default function (err: any) { + return err + .toString() + .replace(new RegExp("[?&]auth=[^&#]*(#.*)?$"), "$1") + .replace(new RegExp("([?&])auth=[^&]*&"), "$1"); +} -- 2.44.1