From 842fbcfc6fb4c2d44eaec15768eb9cc125ecb1c6 Mon Sep 17 00:00:00 2001
From: Damian Stasik <920747+damianstasik@users.noreply.github.com>
Date: Wed, 4 Sep 2024 12:35:44 +0200
Subject: [PATCH] Tweak repo link
Signed-off-by: Damian Stasik <920747+damianstasik@users.noreply.github.com>
---
.../src/components/RepoSidebarBlock/index.tsx | 29 +++++++++++++++----
1 file changed, 23 insertions(+), 6 deletions(-)
diff --git a/frontend/src/components/RepoSidebarBlock/index.tsx b/frontend/src/components/RepoSidebarBlock/index.tsx
index eb7f89c8..c22b54ff 100644
--- a/frontend/src/components/RepoSidebarBlock/index.tsx
+++ b/frontend/src/components/RepoSidebarBlock/index.tsx
@@ -1,13 +1,30 @@
+import { github } from "@/icons/github";
+import { Icon } from "../Icon";
import { SidebarBlock } from "../SidebarBlock";
function getLinkLabel(url: string) {
- const match = url.match(/github\.com\/([^/]+)\/([^/]+)/);
+ try {
+ const parsedUrl = new URL(url);
- if (!match) {
- return null;
- }
+ switch (parsedUrl.hostname) {
+ case "github.com": {
+ const pathParts = parsedUrl.pathname.split("/");
- return `${match[1]}/${match[2]}`;
+ return (
+ <>
+
+
+ {pathParts[1]}/{pathParts[2]}
+
+ >
+ );
+ }
+ default:
+ return `${parsedUrl.hostname}${parsedUrl.pathname}`;
+ }
+ } catch {
+ return url;
+ }
}
interface BlockProps {
@@ -20,7 +37,7 @@ export function RepoSidebarBlock(props: BlockProps) {
{props.link ? (