Preserve query string in % to - redirects, refs #1650

This commit is contained in:
Simon Willison 2022-03-07 08:18:07 -08:00
commit 020effe47b
2 changed files with 16 additions and 3 deletions

View file

@ -1216,6 +1216,8 @@ class DatasetteRouter:
# Try the same path but with "%" replaced by "-"
# and "-" replaced with "-2D"
new_path = request.path.replace("-", "-2D").replace("%", "-")
if request.query_string:
new_path += "?{}".format(request.query_string)
await asgi_send_redirect(send, new_path)
return
# If URL has a trailing slash, redirect to URL without it