Commit d0172d5d by Calen Pennington

Correctly use the regex replacement function to substitute all urls in a particular chunk of text

parent 092247fd
......@@ -5,14 +5,14 @@ PREFIX = '/static/'
STATIC_PATTERN = re.compile(r"""
(?P<quote>['"]) # the opening quotes
{prefix} # the prefix
.*? # everything else in the url
(?P<rest>.*?) # everything else in the url
(?P=quote) # the first matching closing quote
""".format(prefix=PREFIX), re.VERBOSE)
PREFIX_LEN = len(PREFIX)
def replace(static_url):
quote = static_url[0]
url = staticfiles_storage.url(static_url[1+PREFIX_LEN:-1])
quote = static_url.group('quote')
url = staticfiles_storage.url(static_url.group('rest'))
return "".join([quote, url, quote])
def replace_urls(text):
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment