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

The url() method strips trailing slash from the given name #86

Open
alisspers opened this issue May 27, 2019 · 1 comment
Open

The url() method strips trailing slash from the given name #86

alisspers opened this issue May 27, 2019 · 1 comment

Comments

@alisspers
Copy link

We're using the plugin django-ckeditor to add a wysiwyg editor to our models. The package fails to load its static files when used together with django-s3-storage, because of a lost slash when constructing the URL that ends up looking something like this:

https://[my-bucket].s3.eu-central-1.amazonaws.com/ckeditor/ckeditorconfig.js?

while it's supposed to look like this:

https://[my-bucket].s3.eu-central-1.amazonaws.com/ckeditor/ckeditor/config.js?

(notice the missing slash before config.js)

This happens because django-ckeditor calls url() with the name 'ckeditor/ckeditor/', and somewhere along the way this trailing slash is removed.

I've drilled it down to being the _get_key_name that strips the trailing slash.

def _get_key_name(self, name):
if name.startswith("/"):
name = name[1:]
return posixpath.normpath(posixpath.join(self.settings.AWS_S3_KEY_PREFIX, _to_posix_path(name)))

It's using posix.normpath which by design strips trailing slashes.

A proposed solution would be to readd the trailing slash after running normpath (much like the PR in the "sister package" django-storage)

@etianen
Copy link
Owner

etianen commented May 28, 2019 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants