Просмотр исходного кода

Merge pull request #7498 from weseek/fix/not-work-attachment-link

fix: Attachment links do not work correctly
Yuki Takei 3 лет назад
Родитель
Сommit
13ccb4a7e7
1 измененных файлов с 3 добавлено и 5 удалено
  1. 3 5
      packages/app/src/components/ReactMarkdownComponents/NextLink.tsx

+ 3 - 5
packages/app/src/components/ReactMarkdownComponents/NextLink.tsx

@@ -23,10 +23,9 @@ const isExternalLink = (href: string, siteUrl: string | undefined): boolean => {
 };
 };
 
 
 const isAttached = (href: string): boolean => {
 const isAttached = (href: string): boolean => {
-    return href.toString().startsWith('/attachment/');
+  return href.startsWith('/attachment/');
 };
 };
 
 
-
 type Props = Omit<LinkProps, 'href'> & {
 type Props = Omit<LinkProps, 'href'> & {
   children: React.ReactNode,
   children: React.ReactNode,
   href?: string,
   href?: string,
@@ -66,18 +65,17 @@ export const NextLink = (props: Props): JSX.Element => {
 
 
   // when href is an attachment file
   // when href is an attachment file
   if (isAttached(href)) {
   if (isAttached(href)) {
-    const dlhref=href.toString().replace('/attachment/','/download/');
+    const dlhref = href.replace('/attachment/', '/download/');
     return (
     return (
       <span>
       <span>
         <a href={href} className={className} target="_blank" rel="noopener noreferrer" {...dataAttributes}>
         <a href={href} className={className} target="_blank" rel="noopener noreferrer" {...dataAttributes}>
-        {children}
+          {children}
         </a>&nbsp;
         </a>&nbsp;
         <a href={dlhref} className="attachment-download"><i className='icon-cloud-download'></i></a>
         <a href={dlhref} className="attachment-download"><i className='icon-cloud-download'></i></a>
       </span>
       </span>
     );
     );
   }
   }
 
 
-
   return (
   return (
     <Link {...rest} href={href} prefetch={false} legacyBehavior>
     <Link {...rest} href={href} prefetch={false} legacyBehavior>
       <a href={href} className={className} {...dataAttributes}>{children}</a>
       <a href={href} className={className} {...dataAttributes}>{children}</a>