tags:

views:

58

answers:

3
(r'^/(?P<the_param>[a-zA-z0-9_-]+)/$','myproject.myapp.views.myview'),

How can I change this so that "the_param" accepts a URL(encoded) as a parameter?

So, I want to pass a URL to it.

mydomain.com/http%3A//google.com

Edit: Should I remove the regex, like this...and then it would work?

(r'^/(?P[*]?)/?$','myproject.myapp.views.myview'),

+2  A: 

Add % and . to the character class:

[a-zA-z0-9_-%.]

Note: You don't need to escape special characters inside character classes.

Felix Kling
http://rubular.com/ might be worth checking out.
jluebbert
jluebbert: Nice site. I also like this one: http://www.txt2re.com/
Lakshman Prasad
A: 

You'll at least need something like:

(r'^the/uri/is/(?P<uri_encoded>[a-zA-Z0-9~%\._-])$', 'project.app.view'),

That expression should match everything described here.

Note that your example should be mydomain.com/http%3A%2F%2Fgoogle.com (slashes should be encoded).

Seth
A: 

i think you can do it with:

(r'^(?P[\w.~_-]+)$', 'project.app.view')

regards

zerofuxor