Flask routing tweak, don't redirect URLs with empty path elements

pull/79/head
Ryan Barrett 2021-08-06 10:28:56 -07:00
rodzic 40ad6a4afa
commit a27ebc4697
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: 6BE31FDF4776E9D4
2 zmienionych plików z 4 dodań i 1 usunięć

3
app.py
Wyświetl plik

@ -26,6 +26,9 @@ app.url_map.converters['regex'] = flask_util.RegexConverter
app.after_request(flask_util.default_modern_headers)
app.register_error_handler(Exception, flask_util.handle_exception)
# don't redirect API requests with blank path elements
app.url_map.redirect_defaults = True
app.wsgi_app = handlers.ndb_context_middleware(
app.wsgi_app, client=appengine_config.ndb_client)

Wyświetl plik

@ -31,7 +31,7 @@ CACHE_TIME = datetime.timedelta(seconds=15)
@app.get(r'/r/<path:to>')
@cache.cached(timeout=CACHE_TIME.total_seconds(), query_string=True,
response_filter=flask_util.not_5xx)
def redir(to=None):
def redir(to):
"""301 redirect to the embedded fully qualified URL.
e.g. redirects /r/https://foo.com/bar?baz to https://foo.com/bar?baz