Skip to content

Commit d4d6c57

Browse files
committed
Compile URL pattern only one time.
1 parent e4f3e4f commit d4d6c57

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

compressor/filters/css_default.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@
66
from compressor.conf import settings
77
from compressor.utils import get_hexdigest, get_mtime
88

9+
URL_PATTERN = re.compile(r'url\(([^\)]+)\)')
10+
11+
912
class CssAbsoluteFilter(FilterBase):
1013
def input(self, filename=None, **kwargs):
1114
media_root = os.path.abspath(settings.MEDIA_ROOT)
@@ -28,8 +31,7 @@ def input(self, filename=None, **kwargs):
2831
self.media_url = '/'.join(parts[2:])
2932
self.protocol = '%s/' % '/'.join(parts[:2])
3033
self.directory_name = '/'.join([self.media_url, os.path.dirname(self.media_path)])
31-
url_pattern = re.compile(r'url\(([^\)]+)\)')
32-
output = url_pattern.sub(self.url_converter, self.content)
34+
output = URL_PATTERN.sub(self.url_converter, self.content)
3335
return output
3436

3537
def add_mtime(self, url):

0 commit comments

Comments
 (0)