Use urljoin() to compose OAuth URLs instead of string concatenation

String concatenation is bound to mess up; in this case it was producing
double slashes instead of single ones when `BLENDER_ID_ENDPOINT` ends in
a slash. Since URLs generally end in a slash, this should be supported.
This commit is contained in:
2018-08-29 14:17:17 +02:00
parent e8123b7839
commit 2c40665271
3 changed files with 6 additions and 5 deletions

View File

@@ -261,9 +261,9 @@ def setup_app(app, url_prefix):
def switch_user_url(next_url: str) -> str:
from urllib.parse import quote
from urllib.parse import quote, urljoin
base_url = '%s/switch' % current_app.config['BLENDER_ID_ENDPOINT']
base_url = urljoin(current_app.config['BLENDER_ID_ENDPOINT'], 'switch')
if next_url:
return '%s?next=%s' % (base_url, quote(next_url))
return base_url