From 9b922304cf30deb3a0395d95b6f98d1a766c7bab Mon Sep 17 00:00:00 2001
From: Yash <yashverma30115@gmail.com>
Date: Thu, 11 Apr 2024 06:29:18 +0000
Subject: clean url

---
 apps/web/src/components/ChatMessage.tsx | 16 +++++++++++++++-
 1 file changed, 15 insertions(+), 1 deletion(-)

(limited to 'apps/web/src/components/ChatMessage.tsx')

diff --git a/apps/web/src/components/ChatMessage.tsx b/apps/web/src/components/ChatMessage.tsx
index d25c9c48..db0778c4 100644
--- a/apps/web/src/components/ChatMessage.tsx
+++ b/apps/web/src/components/ChatMessage.tsx
@@ -37,7 +37,7 @@ export function ChatAnswer({
                 href={source}
               >
                 <Globe className="h-4 w-4" />
-                {source}
+                {cleanUrl(source)}
               </a>
             ))}
           </div>
@@ -103,3 +103,17 @@ function MessageSkeleton() {
     </div>
   );
 }
+
+function cleanUrl(url: string) {
+  if (url.startsWith("https://")) {
+    url = url.slice(8);
+  } else if (url.startsWith("http://")) {
+    url = url.slice(7);
+  }
+
+  if (url.endsWith("/")) {
+    url = url.slice(0, -1);
+  }
+
+  return url;
+}
-- 
cgit v1.2.3

