#NEWLINE# def clean_http_referer( request , default_referer = '/' ) : #NEWLINE# #INDENT# 'Returns the HTTP referer of the given request.\n    \n    If the HTTP referer is not recognizable, default_referer is returned.\n    ' #NEWLINE# if ( not request ) : #NEWLINE# #INDENT# return default_referer #NEWLINE# #UNINDENT# referer = request . META . get ( 'HTTP_REFERER' , default_referer ) #NEWLINE# return referer . replace ( 'http://' , '' ) . replace ( 'https://' , '' ) . replace ( request . META [ 'HTTP_HOST' ] , '' )