From 31789495a203e6eac815964947985e6508173000 Mon Sep 17 00:00:00 2001 From: SleeplessOne1917 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 ec352d42..996fcdb5 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 { ### 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 00000000..0702b102 --- /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"); +}