Taichi Masuyama 3 лет назад
Родитель
Сommit
2762fd6d62
1 измененных файлов с 10 добавлено и 2 удалено
  1. 10 2
      packages/app/src/components/ReactMarkdownComponents/NextLink.tsx

+ 10 - 2
packages/app/src/components/ReactMarkdownComponents/NextLink.tsx

@@ -8,8 +8,16 @@ const isAnchorLink = (href: string): boolean => {
 };
 
 const isExternalLink = (href: string, siteUrl: string | undefined): boolean => {
-  const baseUrl = new URL(siteUrl ?? 'https://example.com');
-  const hrefUrl = new URL(href, baseUrl);
+  let baseUrl: URL;
+  let hrefUrl: URL;
+
+  try {
+    baseUrl = new URL(siteUrl ?? 'https://example.com');
+    hrefUrl = new URL(href, baseUrl);
+  }
+  catch {
+    return false;
+  }
 
   return baseUrl.host !== hrefUrl.host;
 };