From: SleeplessOne1917 <abias1122@gmail.com>
Date: Sun, 2 Jul 2023 19:45:45 +0000 (-0400)
Subject: Prevent JWT token from showing up on error page
X-Git-Url: http://these/git/%7B%27/docs/static/%24%7B%60data:application/%7Bpost.url%7D?a=commitdiff_plain;h=31789495a203e6eac815964947985e6508173000;p=lemmy-ui.git

Prevent JWT token from showing up on error page
---

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");
+}