From 6826f731c7098bf2228cb375363865fd031b0b4f Mon Sep 17 00:00:00 2001 From: Tanner Collin Date: Thu, 7 Nov 2019 22:10:08 +0000 Subject: [PATCH] Handle hostnames better --- apiserver/server.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/apiserver/server.py b/apiserver/server.py index 72d90a7..4d61e36 100644 --- a/apiserver/server.py +++ b/apiserver/server.py @@ -91,7 +91,8 @@ def static_story(sid): score, 's' if score != 1 else '', num_comments, 's' if num_comments != 1 else '', source) - url = urlparse(story['url']).hostname.replace('www.', '') + url = urlparse(story['url']).hostname or urlparse(story['link']).hostname or '' + url = url.replace('www.', '') return render_template('index.html', title=story['title'],