-
Notifications
You must be signed in to change notification settings - Fork 16
Description
There could be a problem between the keyboard and chair and if this is not a bug I'd love to know what I might be doing wrong. At the least perhaps I could help update the docs.
I would like to catch a URL and include the optional query string and match all of these:
/1/2/
/1/2/?x=4
/1/2/?x=4&y=2
To do this I've got this regex:
/1/2/(\?.*)?$
/1/2/ = base
( = wrapping parens to get $1
\? = literal question mark
.* = zero or more anything except line breaks
)
? = 0 or 1 of what's in the parens
$ = and butt up against the end of the string
If that makes sense, and manual testing shows that these redirect nicely:
/1/2
/1/2?x=4
/1/2/?x=4
/1/2/?x=4&y=2
/1/2/
and these don't, as they shouldn't:
/1/2/#anchor
/1/2/3/
/1/2/3/4
Remove the $ and it expands to match everything above which is undesirable.
When I add $1 to my redirect URL to catch and forward the query string...
/1/2/?x=1 works just fine. But /1/2/ causes an unmatched group error.
Is it possible middleware.py > RedirectFallbackMiddleware.process_response which contains
new_path = redirect.new_path.replace('$', '\\')
might be failing on this?
Thanks!
--
Django==1.9.11
Python==2.7.9
django-regex-redirects==0.0.5

