From 16c845fbe5963f29c6b65991ef792ace84893673 Mon Sep 17 00:00:00 2001
From: Alan Pearce
Date: Mon, 15 Sep 2014 19:30:52 +0100
Subject: Parse an empty document correctly
---
src/microformats/parser.clj | 2 +-
test/microformats/parser_expectations.clj | 3 +++
2 files changed, 4 insertions(+), 1 deletion(-)
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 "author a
author b")))
+
+(expect {:items [] :rels {}}
+ (parse ""))
--
cgit 1.4.1