Minimum refactor to decide_if_cors

remove-default-role
Manuel Kaufmann 2018-05-24 12:14:01 -05:00
parent 2f5ae97d54
commit bd7b9fee7a
1 changed files with 6 additions and 4 deletions

View File

@ -42,15 +42,17 @@ def decide_if_cors(sender, request, **kwargs): # pylint: disable=unused-argumen
if 'HTTP_ORIGIN' not in request.META:
return False
host = urlparse(request.META['HTTP_ORIGIN']).netloc.split(':')[0]
valid_url = False
for url in WHITELIST_URLS:
if request.path_info.startswith(url):
valid_url = True
# Don't do domain checking for this API for now
if request.path_info.startswith('/api/v2/sustainability'):
return True
valid_url = False
for url in WHITELIST_URLS:
if request.path_info.startswith(url):
valid_url = True
break
if valid_url:
project_slug = request.GET.get('project', None)
try: