Browse Source

fix: can't open external links like zotero and mail clients

close #3186
close #3235
Tienson Qin 4 years ago
parent
commit
0452c7ce3e
2 changed files with 11 additions and 1 deletions
  1. 1 1
      src/main/frontend/components/block.cljs
  2. 10 0
      src/main/frontend/util.cljc

+ 1 - 1
src/main/frontend/components/block.cljs

@@ -887,7 +887,7 @@
           (not (string/includes? s "."))
           (page-reference (:html-export? config) s config label)
 
-          (util/safe-re-find #"(?i)^http[s]?://" s)
+          (util/url? s)
           (->elem :a {:href s
                       :data-href s
                       :target "_blank"}

+ 10 - 0
src/main/frontend/util.cljc

@@ -1453,3 +1453,13 @@
            button (gobj/get e "button")]
        (or (= which 3)
            (= button 2)))))
+
+#?(:cljs
+   (defn url?
+     [s]
+     (and (string? s)
+          (try
+            (js/URL. s)
+            true
+            (catch js/Error _e
+              false)))))