Skip to content

Commit 211b912

Browse files
mkphilippamarkovics
authored andcommitted
Ensure var->location returns a string path location
1 parent d96a399 commit 211b912

File tree

1 file changed

+10
-9
lines changed

1 file changed

+10
-9
lines changed

src/nextjournal/clerk/analyzer.clj

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -454,15 +454,16 @@
454454

455455
(defn var->location [var]
456456
(when-let [file (:file (meta var))]
457-
(if (fs/absolute? file)
458-
(when (fs/exists? file)
459-
(fs/relativize (fs/cwd) (fs/file file)))
460-
(when-let [resource (io/resource file)]
461-
(let [protocol (.getProtocol resource)]
462-
(or (and (= "jar" protocol)
463-
(second (re-find #"^file:(.*)!" (.getFile resource))))
464-
(and (= "file" protocol)
465-
(.getFile resource))))))))
457+
(some-> (if (fs/absolute? file)
458+
(when (fs/exists? file)
459+
(fs/relativize (fs/cwd) (fs/file file)))
460+
(when-let [resource (io/resource file)]
461+
(let [protocol (.getProtocol resource)]
462+
(or (and (= "jar" protocol)
463+
(second (re-find #"^file:(.*)!" (.getFile resource))))
464+
(and (= "file" protocol)
465+
(.getFile resource))))))
466+
str)))
466467

467468
(defn find-location [sym]
468469
(if (deref? sym)

0 commit comments

Comments
 (0)