Compare commits

...

2 Commits

Author SHA1 Message Date
sqozz eda9cae667 Fix handling of empty requests 2018-06-09 21:57:17 +02:00
sqozz 810f922927 Fix typo 2018-06-09 21:56:47 +02:00
2 changed files with 3 additions and 2 deletions

View File

@ -36,10 +36,11 @@ def short(shortLink=""):
else:
return render_template("index.html", name=shortLink) # Landing page
elif request.method == "POST": # Someone submitted a new link to short
longUrl = request.form["url"] # required, accept the exception if the key does not exist
longUrl = request.form.get("url", "")
wishId = request.form.get("wishId")
if len(longUrl) <= 0:
abort(400)
databaseId = insertIdUnique(longUrl, idToCheck=wishId)
return request.url_root + databaseId # Short link in plain text

View File

@ -51,7 +51,7 @@ class SchortRegressionTests(unittest.TestCase, WebTestCase):
req = requests.post(BASE_URL + "/", data={"url": ""})
self.assertEqual(req.status_code, 400, msg="Could not handle a request with empty url")
req = requests.post(BASE_URL + "/", data={})
self.assertEqual(req.status_code, 400, msg="Could not handle a request with url at all")
self.assertEqual(req.status_code, 400, msg="Could not handle a request without a url at all")
class SchortShortLinkCase(object):