about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorAlan Pearce2014-09-15 19:30:52 +0100
committerAlan Pearce2014-09-15 19:30:52 +0100
commit16c845fbe5963f29c6b65991ef792ace84893673 (patch)
tree55777a0fd7bf181581c592e1caab683cc1d65a1d
parentd44305ac37fe2d92aad4bb0ef5602133050d4f2a (diff)
downloadmicroformats-16c845fbe5963f29c6b65991ef792ace84893673.tar.lz
microformats-16c845fbe5963f29c6b65991ef792ace84893673.tar.zst
microformats-16c845fbe5963f29c6b65991ef792ace84893673.zip
Parse an empty document correctly
-rw-r--r--src/microformats/parser.clj2
-rw-r--r--test/microformats/parser_expectations.clj3
2 files changed, 4 insertions, 1 deletions
diff --git a/src/microformats/parser.clj b/src/microformats/parser.clj
index 9801515..573d3e2 100644
--- a/src/microformats/parser.clj
+++ b/src/microformats/parser.clj
@@ -157,7 +157,7 @@
 (defn parse-rels
   "Parse rel attibutes of a set of HTML link elements"
   [elements]
-  (apply merge-with into (map parse-rel (select-rels elements))))
+  (or (apply merge-with into (map parse-rel (select-rels elements))) {}))
 
 (defn parse
   "Parse a HTML string with microformats"
diff --git a/test/microformats/parser_expectations.clj b/test/microformats/parser_expectations.clj
index 742b8e7..d8b7225 100644
--- a/test/microformats/parser_expectations.clj
+++ b/test/microformats/parser_expectations.clj
@@ -99,3 +99,6 @@
 (expect {:author ["http://example.com/a" "http://example.com/b"]}
         (parse-rels (html-snippet "<a rel=\"author\" href=\"http://example.com/a\">author a</a>
 <a rel=\"author\" href=\"http://example.com/b\">author b</a>")))
+
+(expect {:items [] :rels {}}
+        (parse ""))