Skip to content

Commit

Permalink
fixed https support (is_secure() is not reliable in some scenarios, l…
Browse files Browse the repository at this point in the history
…ike when it's behind an ssl terminating proxy)
  • Loading branch information
tals committed Mar 20, 2014
1 parent 27fd8ee commit 1ccf8ae
Showing 1 changed file with 1 addition and 5 deletions.
6 changes: 1 addition & 5 deletions flask_moment.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,7 @@ class _moment(object):
@staticmethod
def include_moment(version = '2.5.1'):
if version is not None:
if request.is_secure:
scheme = 'https'
else:
scheme = 'http'
js = '<script src="%s://cdnjs.cloudflare.com/ajax/libs/moment.js/%s/moment-with-langs.min.js"></script>\n' % (scheme, version)
js = '<script src="//cdnjs.cloudflare.com/ajax/libs/moment.js/%s/moment-with-langs.min.js"></script>\n' % version
return Markup('''%s<script>
function flask_moment_render(elem) {
$(elem).text(eval('moment("' + $(elem).data('timestamp') + '").' + $(elem).data('format') + ';'));
Expand Down

0 comments on commit 1ccf8ae

Please sign in to comment.