redirects: Refactor redirect code to use central helper function.

This commit introduces two new functions in 'url_encoding.py' which
centralize two common patterns for constructing redirect URLs. It
also migrates the files using those patterns to use the new
functions.
This commit is contained in:
Graham Bleaney
2020-03-02 13:38:16 -05:00
committed by Tim Abbott
parent 5dca599481
commit 2fe9d85a5f
6 changed files with 26 additions and 14 deletions

View File

@@ -97,3 +97,10 @@ def near_pm_message_url(realm: Realm,
]
full_url = '/'.join(parts)
return full_url
def add_query_to_redirect_url(original_url: str, query: str) -> str:
return original_url + "?" + query
def add_query_arg_to_redirect_url(original_url: str, query_arg: str) -> str:
assert '?' in original_url
return original_url + "&" + query_arg