Simplify, make it actually work.
- regexp was too complicated, didn't work
This commit is contained in:
@@ -16,18 +16,14 @@ def _url_replace_regex(prefix):
|
||||
"""
|
||||
Match static urls in quotes that don't end in '?raw'.
|
||||
|
||||
I'm sorry. http://xkcd.com/1171/
|
||||
|
||||
(?<!blah) means "don't match if the previous thing is blah". Clear, eh?
|
||||
(grep for negative lookbehind assertion in
|
||||
http://docs.python.org/2/library/re.html)
|
||||
To anyone contemplating making this more complicated:
|
||||
http://xkcd.com/1171/
|
||||
"""
|
||||
return r"""
|
||||
(?x) # flags=re.VERBOSE
|
||||
(?P<quote>\\?['"]) # the opening quotes
|
||||
(?P<prefix>{prefix}) # the prefix
|
||||
(?P<rest>.*? # everything else in the url...
|
||||
(?<!\?raw)) # ...but not if it has '?raw' at the end.
|
||||
(?P<rest>.*?) # everything else in the url
|
||||
(?P=quote) # the first matching closing quote
|
||||
""".format(prefix=prefix)
|
||||
|
||||
@@ -84,6 +80,10 @@ def replace_static_urls(text, data_directory, course_namespace=None):
|
||||
quote = match.group('quote')
|
||||
rest = match.group('rest')
|
||||
|
||||
# Don't mess with things that end in '?raw'
|
||||
if rest.endswith('?raw'):
|
||||
return original
|
||||
|
||||
# course_namespace is not None, then use studio style urls
|
||||
if course_namespace is not None and not isinstance(modulestore(), XMLModuleStore):
|
||||
url = StaticContent.convert_legacy_static_url(rest, course_namespace)
|
||||
|
||||
Reference in New Issue
Block a user