Repository: pyupio/changelogs

Issue:
Url validation ignored
```In [12]: changelogs.get('1')                                                                                           
---------------------------------------------------------------------------
MissingSchema                             Traceback (most recent call last)
<ipython-input-12-47f2b1bcf4e3> in <module>
----> 1 changelogs.get('1')

~/src/cve-search/env/lib/python3.6/site-packages/changelogs/changelogs.py in get(name, vendor, functions, _depth)
    166         data=data,
    167         releases=releases,
--> 168         find_changelogs_fn=fns["find_changelogs"]
    169     )
    170 

~/src/cve-search/env/lib/python3.6/site-packages/changelogs/pypi.py in get_urls(session, name, data, find_changelogs_fn, **kwargs)
     91         if data['info']['description']:
     92             candidates.extend(changelogs.url_re.findall(data["info"]["description"]))
---> 93         return find_changelogs_fn(session=session, name=name, candidates=candidates)
     94     return set(), set()

~/src/cve-search/env/lib/python3.6/site-packages/changelogs/finder.py in find_changelogs(session, name, candidates)
    217     if not repos:
    218         logger.info("No repo found, trying to find one on related sites {}".format(candidates))
--> 219         repos = set(find_repo_urls(session, name, candidates))
    220 
    221     urls = []

~/src/cve-search/env/lib/python3.6/site-packages/changelogs/finder.py in find_repo_urls(session, name, candidates)
     71         if validate_url(_url):
     72             try:
---> 73                 resp = session.get(_url)
     74                 if resp.status_code == 200:
     75                     tree = etree.HTML(resp.content)

~/src/cve-search/env/lib/python3.6/site-packages/requests/sessions.py in get(self, url, **kwargs)
    523 
    524         kwargs.setdefault('allow_redirects', True)
--> 525         return self.request('GET', url, **kwargs)
    526 
    527     def options(self, url, **kwargs):

~/src/cve-search/env/lib/python3.6/site-packages/requests/sessions.py in request(self, method, url, params, data, headers, cookies, files, auth, timeout, allow_redirects, proxies, hooks, stream, verify, cert, json)
    496             hooks=hooks,
    497         )
--> 498         prep = self.prepare_request(req)
    499 
    500         proxies = proxies or {}

~/src/cve-search/env/lib/python3.6/site-packages/requests/sessions.py in prepare_request(self, request)
    439             auth=merge_setting(auth, self.auth),
    440             cookies=merged_cookies,
--> 441             hooks=merge_hooks(request.hooks, self.hooks),
    442         )
    443         return p

~/src/cve-search/env/lib/python3.6/site-packages/requests/models.py in prepare(self, method, url, headers, files, data, params, auth, cookies, hooks, json)
    307 
    308         self.prepare_method(method)
--> 309         self.prepare_url(url, params)
    310         self.prepare_headers(headers)
    311         self.prepare_cookies(cookies)

~/src/cve-search/env/lib/python3.6/site-packages/requests/models.py in prepare_url(self, url, params)
    381             error = error.format(to_native_string(url, 'utf8'))
    382 
--> 383             raise MissingSchema(error)
    384 
    385         if not host:

MissingSchema: Invalid URL 'gxc.online': No schema supplied. Perhaps you meant http://gxc.online?
```

Basically, [this line](https://github.com/pyupio/changelogs/blob/0cdb929ac4546c766cd7eef9ae4eb4baaa08f452/changelogs/finder.py#L71) should be like this:
```
        _url = validate_url(_url)                                                                               
        if _url:  
```
I'm gonna send a PR soon unless you fix it before that.

Comments:

Patch:
diff --git a/changelogs/finder.py b/changelogs/finder.py
index c34bbd2..8bba1e5 100644
--- a/changelogs/finder.py
+++ b/changelogs/finder.py
@@ -68,7 +68,8 @@ def find_repo_urls(session, name, candidates):
     :return: str, URL to a repo
     """
     for _url in candidates:
-        if validate_url(_url):
+        _url = validate_url(_url)
+        if _url:
             try:
                 resp = session.get(_url)
                 if resp.status_code == 200:


Test patch:
diff --git a/tests/test_finder.py b/tests/test_finder.py
index a127632..0631ad4 100644
--- a/tests/test_finder.py
+++ b/tests/test_finder.py
@@ -1,4 +1,6 @@
-from changelogs.finder import contains_project_name
+from unittest.mock import Mock
+
+from changelogs.finder import contains_project_name, find_repo_urls
 
 
 def test_contains_project_name():
@@ -19,5 +21,19 @@ def test_not_contains_project_name():
     assert not call('dj-dashboard', 'https://github.com/pydanny/cookiecutter-djangopackage')
 
 
-def test_find_repo_urls():
-    pass
+def test_find_repo_urls_invalid_candidate():
+    session = Mock()
+    list(find_repo_urls(session, 'foobar', ['invalid-link']))
+    assert not session.get.called
+
+
+def test_find_repo_urls_valid_candidate():
+    session = Mock()
+    list(find_repo_urls(session, 'foobar', ['http://example.com/link']))
+    session.get.assert_called_with('http://example.com/link')
+
+
+def test_find_repo_urls_domain_candidate():
+    session = Mock()
+    list(find_repo_urls(session, 'foobar', ['example.com']))
+    session.get.assert_called_with('http://example.com')