1
0
Fork 0

Fix url input and mark it as required

Validation is done in html on the client
and raises an error 400 in the api.

This fixes #2.
Dieser Commit ist enthalten in:
sqozz 2018-05-01 03:53:11 +02:00
Ursprung f74aedc547
Commit 154df1af2b
2 geänderte Dateien mit 3 neuen und 1 gelöschten Zeilen

Datei anzeigen

@ -38,6 +38,8 @@ def short(shortLink=""):
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
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

Datei anzeigen

@ -12,7 +12,7 @@
</div>
<form action="/" method="post" id="short_form">
<span id="url_text">URL:</span>
<input type="input" name="url" id="url_input">
<input type="url" name="url" id="url_input" required>
<input type="hidden" name="wishId" value="{{name}}">
<input type="submit" value="Schort!" id="short_button">
</form>