You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
12 lines
408 B
12 lines
408 B
# -*- coding: utf-8 -*-
|
|
import re
|
|
|
|
def get_referer(request, default=None):
|
|
referer = request.META.get('HTTP_REFERER')
|
|
if not referer:
|
|
return default
|
|
# remove the protocol and split the url at the slashes
|
|
referer = re.sub('^https?:\/\/', '', referer).split('/')
|
|
# add the slash at the relative path's view and finished
|
|
referer = u'/' + u'/'.join(referer[1:])
|
|
return referer |