Skip to content

Commit

Permalink
clean url
Browse files Browse the repository at this point in the history
  • Loading branch information
yxshv committed Apr 11, 2024
1 parent 257e355 commit 9b92230
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion apps/web/src/components/ChatMessage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ export function ChatAnswer({
href={source}
>
<Globe className="h-4 w-4" />
{source}
{cleanUrl(source)}
</a>
))}
</div>
Expand Down Expand Up @@ -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;
}

0 comments on commit 9b92230

Please sign in to comment.