Skip to content

Commit

Permalink
encode urls for template context
Browse files Browse the repository at this point in the history
  • Loading branch information
sheppard committed Dec 5, 2014
1 parent c819cf5 commit 0e1de58
Showing 1 changed file with 14 additions and 4 deletions.
18 changes: 14 additions & 4 deletions rest/context_processors.py
@@ -1,17 +1,27 @@
from .app import router
from django.utils.http import urlquote


def version(request):
return {'version': router.version}


def pages_info(request):
# FIXME: support non-root base_url
base_url = ""
path = request.path[1:]
if request.GET:
path += "?" + request.GET.urlencode()
full_path = base_url + "/" + path

info = {
'base_url': "",
'full_path': request.path,
'path': request.path[1:],
'prev_path': '', # Referer?
'base_url': base_url,
'path': path,
'path_enc': urlquote(path),
'params': request.GET,
'full_path': full_path,
'full_path_enc': urlquote(full_path),
'prev_path': '', # Referer?
}

return {
Expand Down

0 comments on commit 0e1de58

Please sign in to comment.