Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
E
edx-platform
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
edx
edx-platform
Commits
959c97d7
Commit
959c97d7
authored
Jun 23, 2016
by
Toby Lawrence
Committed by
GitHub
Jun 23, 2016
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #12821 from edx/PERF-341
[PERF-341] Don't rewrite XBlock resource URLs.
parents
d20e5455
faaa30c0
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
23 additions
and
0 deletions
+23
-0
common/djangoapps/static_replace/__init__.py
+8
-0
common/djangoapps/static_replace/test/test_static_replace.py
+15
-0
No files found.
common/djangoapps/static_replace/__init__.py
View file @
959c97d7
...
...
@@ -13,6 +13,7 @@ from xmodule.contentstore.content import StaticContent
from
opaque_keys.edx.locator
import
AssetLocator
log
=
logging
.
getLogger
(
__name__
)
XBLOCK_STATIC_RESOURCE_PREFIX
=
'/static/xblock'
def
_url_replace_regex
(
prefix
):
...
...
@@ -109,6 +110,13 @@ def process_static_urls(text, replacement_function, data_dir=None):
prefix
=
match
.
group
(
'prefix'
)
quote
=
match
.
group
(
'quote'
)
rest
=
match
.
group
(
'rest'
)
# Don't rewrite XBlock resource links. Probably wasn't a good idea that /static
# works for actual static assets and for magical course asset URLs....
full_url
=
prefix
+
rest
if
full_url
.
startswith
(
XBLOCK_STATIC_RESOURCE_PREFIX
):
return
original
return
replacement_function
(
original
,
prefix
,
quote
,
rest
)
return
re
.
sub
(
...
...
common/djangoapps/static_replace/test/test_static_replace.py
View file @
959c97d7
...
...
@@ -196,6 +196,21 @@ def test_regex():
assert_false
(
re
.
match
(
regex
,
s
))
@patch
(
'static_replace.staticfiles_storage'
,
autospec
=
True
)
@patch
(
'static_replace.modulestore'
,
autospec
=
True
)
def
test_static_url_with_xblock_resource
(
mock_modulestore
,
mock_storage
):
"""
Make sure that for URLs with XBlock resource URL, which start with /static/,
we don't rewrite them.
"""
mock_storage
.
exists
.
return_value
=
False
mock_modulestore
.
return_value
=
Mock
(
MongoModuleStore
)
pre_text
=
'EMBED src ="/static/xblock/resources/babys_first.lil_xblock/public/images/pacifier.png"'
post_text
=
pre_text
assert_equals
(
post_text
,
replace_static_urls
(
pre_text
,
DATA_DIRECTORY
,
COURSE_KEY
))
@ddt.ddt
class
CanonicalContentTest
(
SharedModuleStoreTestCase
):
"""
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment