소스 검색

Add http prefix to listed golinks to not make them point to go/go/...

Taddeus Kroes 6 일 전
부모
커밋
7df9b12dcb
1개의 변경된 파일5개의 추가작업 그리고 1개의 파일을 삭제
  1. 5 1
      ui/src/LinksPage/LinksView/ShortLink/ShortLink.tsx

+ 5 - 1
ui/src/LinksPage/LinksView/ShortLink/ShortLink.tsx

@@ -7,11 +7,15 @@ export interface ShortLinkProps {
 export const ShortLink = ({ url }: ShortLinkProps) => {
   return (
     <div className={css.shortlink}>
-      <a href={url}>{stripScheme(url)}</a>
+      <a href={ensureHttp(url)}>{stripScheme(url)}</a>
     </div>
   );
 };
 
+function ensureHttp(url: string): string {
+  return url.startsWith('http') ? url : `http://${url}`;
+}
+
 function stripScheme(url: string): string {
   return url.replace(/^https?:\/\//, "");
 }