Quellcode durchsuchen

Fix displaying urls in location fields

Zed vor 6 Jahren
Ursprung
Commit
0582e2ea95
2 geänderte Dateien mit 4 neuen und 1 gelöschten Zeilen
  1. 1 0
      src/formatters.nim
  2. 3 1
      src/views/profile.nim

+ 1 - 0
src/formatters.nim

@@ -117,6 +117,7 @@ proc getTwitterLink*(path: string; params: Table[string, string]): string =
     result = result.replace("/" & username, "")
     result = result.replace("/" & username, "")
 
 
 proc getLocation*(u: Profile | Tweet): (string, string) =
 proc getLocation*(u: Profile | Tweet): (string, string) =
+  if "://" in u.location: return (u.location, "")
   let loc = u.location.split(":")
   let loc = u.location.split(":")
   let url = if loc.len > 1: "/search?q=place:" & loc[1] else: ""
   let url = if loc.len > 1: "/search?q=place:" & loc[1] else: ""
   (loc[0], url)
   (loc[0], url)

+ 3 - 1
src/views/profile.nim

@@ -31,9 +31,11 @@ proc renderProfileCard*(profile: Profile; prefs: Prefs): VNode =
       if profile.location.len > 0:
       if profile.location.len > 0:
         tdiv(class="profile-location"):
         tdiv(class="profile-location"):
           span: icon "location"
           span: icon "location"
-          let (place, url) = profile.getLocation()
+          let (place, url) = getLocation(profile)
           if url.len > 1:
           if url.len > 1:
             a(href=url): text place
             a(href=url): text place
+          elif "://" in place:
+            a(href=place): text place
           else:
           else:
             span: text place
             span: text place