Skip to content

Commit

Permalink
Fix redirect location to handle / (#2204)
Browse files Browse the repository at this point in the history
b/236404667
  • Loading branch information
oxve committed Jan 12, 2024
1 parent e9cde16 commit 9028632
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions cobalt/site/deploy/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,14 @@ def app(environ, start_response):
Changing the file or function name requires configuring a matching entrypoint.
"""
base_url = 'https://developers.google.com'
path_prefix = '/youtube/cobalt/docs'
base_url = 'https://developers.google.com/youtube/cobalt'
doc_prefix = '/docs'
# Remove extension from filename if present.
doc_path = os.path.splitext(environ['RAW_URI'])[0]
if not doc_path or doc_path == '/':
location = base_url
else:
location = f'{base_url}{doc_prefix}{doc_path}'

start_response('301 Moved Permanently',
[('Location', f'{base_url}{path_prefix}{doc_path}')])
start_response('301 Moved Permanently', [('Location', location)])
return []

0 comments on commit 9028632

Please sign in to comment.