Skip to content

Commit

Permalink
Remove double slash in form media
Browse files Browse the repository at this point in the history
If `settings.STATIC_URL` ends in a slash, it may raise a `SuspiciousOperation` error when run through tools like django-compressor. Removing trailing slashes from STATIC_URL fixes this.
  • Loading branch information
BrianHicks committed Apr 2, 2013
1 parent 106eb62 commit 1f02063
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions pagedown/widgets.py
Expand Up @@ -12,9 +12,9 @@ class Media:
css = { css = {
'all': ('pagedown/demo/browser/demo.css',) 'all': ('pagedown/demo/browser/demo.css',)
} }
js = ('%s/pagedown/Markdown.Converter.js' % settings.STATIC_URL, js = ('%s/pagedown/Markdown.Converter.js' % settings.STATIC_URL.rstrip('/'),
'%s/pagedown/Markdown.Sanitizer.js' % settings.STATIC_URL, '%s/pagedown/Markdown.Sanitizer.js' % settings.STATIC_URL.rstrip('/'),
'%s/pagedown/Markdown.Editor.js' % settings.STATIC_URL,) '%s/pagedown/Markdown.Editor.js' % settings.STATIC_URL.rstrip('/'),)


def render(self, name, value, attrs=None): def render(self, name, value, attrs=None):
if value is None: if value is None:
Expand Down

2 comments on commit 1f02063

@timmyomahony
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well spotted. Maybe I should actually rewrite the strings to %spagedown/Markdown.Converter.js (minus the starting slash) as the django docs recommend that the STATIC_URL always end in a slash? Although this way would ensure it works in both situtations

@BrianHicks
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's what I was thinking - I've worked on projects both ways. I think it's better to work with the complete range of input rather than hard-coding it in either direction. Principle of least astonishment and all that.

Please sign in to comment.