Skip to content

Commit

Permalink
Fixes #69 - check if the encoded base64 string is not empty.
Browse files Browse the repository at this point in the history
  • Loading branch information
yosiat committed Dec 20, 2014
1 parent c3fbf93 commit 203d503
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 203d503

Please sign in to comment.