Ticket #18495: urlresolvers_remove_prefix_from_path.diff

File urlresolvers_remove_prefix_from_path.diff, 853 bytes (added by django@…, 3 years ago)

fix proposal #1 to strip script prefix in core/urlresolvers.py:resolve()

  • django/core/urlresolvers.py

    diff --git a/django/core/urlresolvers.py b/django/core/urlresolvers.py
    index 1497d43..574dc92 100644
    a b class RegexURLResolver(LocaleRegexProvider): 
    295295        match = self.regex.search(path)
    296296        if match:
    297297            new_path = path[match.end():]
     298            # Get script prefix, apply regexp and remove from path if present.
     299            prefix = get_script_prefix()
     300            if prefix:
     301                match = self.regex.search(prefix)
     302                if match:
     303                    prefix = prefix[match.end():]
     304                    if new_path.startswith(prefix):
     305                        new_path = new_path[len(prefix):]
    298306            for pattern in self.url_patterns:
    299307                try:
    300308                    sub_match = pattern.resolve(new_path)
Back to Top