Ticket #2476: common-update.diff
File common-update.diff, 1.1 KB (added by , 18 years ago) |
---|
-
django/middleware/common.py
29 29 if user_agent_regex.search(request.META['HTTP_USER_AGENT']): 30 30 return http.HttpResponseForbidden('<h1>Forbidden</h1>') 31 31 32 # Check for a redirect based on settings.APPEND_SLASH and settings.PREPEND_WWW32 # Check for a redirect based on settings.APPEND_SLASH, settings.PREPEND_WWW, and settings.REMOVE_WWW 33 33 host = http.get_host(request) 34 34 old_url = [host, request.path] 35 35 new_url = old_url[:] 36 36 if settings.PREPEND_WWW and old_url[0] and not old_url[0].startswith('www.'): 37 37 new_url[0] = 'www.' + old_url[0] 38 if settings.REMOVE_WWW and old_url[0] and old_url[0].startswith('www.'): 39 new_url[0] = old_url[4:] 38 40 # Append a slash if append_slash is set and the URL doesn't have a 39 41 # trailing slash or a file extension. 40 42 if settings.APPEND_SLASH and (old_url[1][-1] != '/') and ('.' not in old_url[1].split('/')[-1]):