Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#391 Allow COMPRESS_URL to use relative protocols #394

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
15 changes: 11 additions & 4 deletions compressor/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,15 +65,22 @@ def get_template_name(self, mode):
return "compressor/%s_%s.html" % (self.type, mode)

def get_basename(self, url):
"""
Given a url check if it matches the compress url setting, if not error.
:param url:
:return:
"""
try:
base_url = self.storage.base_url
except AttributeError:
base_url = settings.COMPRESS_URL
if not url.startswith(base_url):
raise UncompressableFileError("'%s' isn't accessible via "
"COMPRESS_URL ('%s') and can't be "

if not url.find(base_url) >= 0:
raise UncompressableFileError("'%s' isn't accessible as uri stems don't match via "
"COMPRESS_URL ('%s') and thus can't be "
"compressed" % (url, base_url))
basename = url.replace(base_url, "", 1)
pass
basename = url.split(base_url)[1]
# drop the querystring, which is used for non-compressed cache-busting.
return basename.split("?", 1)[0]

Expand Down