Skip to content

Commit

Permalink
Merge pull request #70 from yosiat/empty_contents
Browse files Browse the repository at this point in the history
Fixes #69 - check if the encoded base64 string is not empty.
  • Loading branch information
Raynes committed Dec 22, 2014
2 parents e07c13a + 203d503 commit 590cdd6
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions src/tentacles/repos.clj
Original file line number Diff line number Diff line change
Expand Up @@ -422,11 +422,13 @@
([res str? path]
(if (and (map? res) (= (:encoding res) "base64"))
(if-let [^String encoded (get-in res path)]
(let [trimmed (.replace encoded "\n" "")
raw (.getBytes trimmed "UTF-8")
decoded (if (seq raw) (b64/decode raw) (byte-array))
done (if str? (String. decoded "UTF-8") decoded)]
(assoc-in res path done))
(if (not (empty? encoded))
(let [trimmed (.replace encoded "\n" "")
raw (.getBytes trimmed "UTF-8")
decoded (if (seq raw) (b64/decode raw) (byte-array))
done (if str? (String. decoded "UTF-8") decoded)]
(assoc-in res path done))
res)
res)
res))
([res str?] (decode-b64 res str? [:content]))
Expand Down

0 comments on commit 590cdd6

Please sign in to comment.