فهرست منبع

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