Permalink
Browse files

Merge pull request #5 from turbovote/fix-npe-when-no-keywords

stop causing NPE when no keywords are present
  • Loading branch information...
KushalP committed Oct 7, 2013
2 parents d58ba74 + c34e427 commit 6fd0caeff2ee8f26fbb0ea634917ee3c2f7f1053
Showing with 7 additions and 1 deletion.
  1. BIN resources/pdf/blank.pdf
  2. +3 −1 src/camelot/metadata.clj
  3. +4 −0 test/camelot/test/metadata.clj
View
Binary file not shown.
View
@@ -12,7 +12,9 @@
{:author (.getAuthor info)
:title (.getTitle info)
:subject (.getSubject info)
- :keywords (str/split (.getKeywords info) #", ")
+ :keywords (if-let [keywords (.getKeywords info)]
+ (str/split keywords #", ")
+ [])
:trapped (.getTrapped info)
:creator (.getCreator info)
:pages (.getNumberOfPages doc)
@@ -26,6 +26,10 @@
:modified nil
:producer nil}))))
+(deftest get-metadata-handles-nil-keywords
+ (let [filename "resources/pdf/blank.pdf"]
+ (is (:keywords (get-metadata filename) []))))
+
(deftest set-metadata-saves-metadata-to-pddocument
(let [metadata {:author "Joe Bloggs"
:title "Hello World"

0 comments on commit 6fd0cae

Please sign in to comment.