def get_search_url_from_referer(request):
 referer = request.META.get('HTTP_REFERER', None)
 try:
  url = URL(referer)
 except UnicodeDecodeError:
  url = None
 current_site = Site.objects.get_current()
 if ((referer is None) or (url is None) or (url.scheme != 'https') or (url.netloc != current_site.domain) or (reverse('search', locale=request.LANGUAGE_CODE) != url.path)):
  return None
 return referer

def get_search_url_from_referer ( request ) : referer = request . META . get ( 'HTTP_REFERER' , None ) try : url = URL ( referer ) except UnicodeDecodeError : url = None current_site = Site . objects . get_current ( ) if ( ( referer is None ) or ( url is None ) or ( url . scheme != 'https' ) or ( url . netloc != current_site . domain ) or ( reverse ( 'search' , locale = request . LANGUAGE_CODE ) != url . path ) ) : return None return referer
returns search url from referer if it was an mdn search .