mirror of
https://github.com/django/django.git
synced 2025-11-07 07:15:35 +00:00
Fixed #17734 -- Made sure to only redirect translated URLs if they can actually be resolved to prevent unwanted redirects. Many thanks to Orne Brocaar and Anssi Kääriäinen for input.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@17621 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
@@ -518,3 +518,17 @@ def get_urlconf(default=None):
|
||||
changed from the default one.
|
||||
"""
|
||||
return getattr(_urlconfs, "value", default)
|
||||
|
||||
def is_valid_path(path, urlconf=None):
|
||||
"""
|
||||
Returns True if the given path resolves against the default URL resolver,
|
||||
False otherwise.
|
||||
|
||||
This is a convenience method to make working with "is this a match?" cases
|
||||
easier, avoiding unnecessarily indented try...except blocks.
|
||||
"""
|
||||
try:
|
||||
resolve(path, urlconf)
|
||||
return True
|
||||
except Resolver404:
|
||||
return False
|
||||
|
||||
Reference in New Issue
Block a user