From f78162fd41cc4f0aa9df0e5273da4ee34cd0cc9f Mon Sep 17 00:00:00 2001 From: Jeena Date: Wed, 3 Aug 2016 21:34:49 +0200 Subject: [PATCH] While parsing check for existance of attribute When parsing rel attributes, check for existance of the href attribute before extracting the text, sometimes like in this post somewhere https://www.patreon.com/posts/jeenas-excellent-6467133 it might be empty and causes an exception. All the other uses above this one check that too. --- lib/microformats2/collection.rb | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/microformats2/collection.rb b/lib/microformats2/collection.rb index 5ed43e0..f33b0cf 100644 --- a/lib/microformats2/collection.rb +++ b/lib/microformats2/collection.rb @@ -103,7 +103,9 @@ module Microformats2 else rel_values.each do |rel_value| @rels[rel_value] = [] unless @rels.has_key?(rel_value) - @rels[rel_value] << Microformats2::AbsoluteUri.new(@base, rel.attribute("href").text).absolutize + unless rel.attribute("href").nil? + @rels[rel_value] << Microformats2::AbsoluteUri.new(@base, rel.attribute("href").text).absolutize + end end end end