From d0172d5d282a70ec381f40a31ed2455a33f8ae05 Mon Sep 17 00:00:00 2001 From: Calen Pennington Date: Fri, 18 May 2012 11:26:42 -0400 Subject: [PATCH] Correctly use the regex replacement function to substitute all urls in a particular chunk of text --- lib/static_replace.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/static_replace.py b/lib/static_replace.py index d820990740..c6c6dd0bc2 100644 --- a/lib/static_replace.py +++ b/lib/static_replace.py @@ -5,14 +5,14 @@ PREFIX = '/static/' STATIC_PATTERN = re.compile(r""" (?P['"]) # the opening quotes {prefix} # the prefix -.*? # everything else in the url +(?P.*?) # 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):