Repository: scottwernervt/favicon

Issue:
'NoneType' object has no attribute 'strip'
Hi, thanks for this awesome egg :)

I think that I found a bug when a [website](https://aol.com/) contains this meta: `<link href="" rel="shortcut icon"/>` .

This causes `tag.get('href') or tag.get('content')` at favicon.py to return `None` instead of a string.

You may want to not include metas with empty href/content into the one to parse :blush: 

Thank you in advance for your time and I wish you a great week :)


Discussion:

Patch:
diff --git a/src/favicon/favicon.py b/src/favicon/favicon.py
index d74471b..fcf0638 100644
--- a/src/favicon/favicon.py
+++ b/src/favicon/favicon.py
@@ -124,7 +124,7 @@ def tags(url, html):
 
     icons = set()
     for tag in link_tags | meta_tags:
-        href = tag.get('href') or tag.get('content')
+        href = tag.get('href', '') or tag.get('content', '')
         href = href.strip()
 
         if not href or href.startswith('data:image/'):


Test patch:
diff --git a/tests/test_favicon.py b/tests/test_favicon.py
index 0fec2f2..96f4cf3 100644
--- a/tests/test_favicon.py
+++ b/tests/test_favicon.py
@@ -116,6 +116,16 @@ def test_link_tag_href_attribute(m, link, url):
     assert icon.url == url
 
 
+def test_link_tag_empty_href_attribute(m):
+    """'NoneType' object has no attribute 'strip' #22"""
+    m.get('http://mock.com/', text='<link rel="icon" href="">')
+
+    with pytest.warns(None):
+        icons = favicon.get('http://mock.com/')
+
+    assert not icons
+
+
 @pytest.mark.parametrize(
     'meta_tag',
     [
@@ -143,6 +153,7 @@ def test_invalid_meta_tag(m):
 
 
 def test_request_kwargs(m):
+    """Add request timeout #21"""
     headers = {
         'User-Agent': 'Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Firefox/68.0'
     }