Skip to content

Commit

Permalink
Fix support for secure_url (#110)
Browse files Browse the repository at this point in the history
  • Loading branch information
yakky committed Jul 7, 2020
1 parent dee630a commit f1b0e66
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 2 deletions.
5 changes: 3 additions & 2 deletions meta/templatetags/meta.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,9 +120,10 @@ def og_prop(name, value):
:param name: property name (without 'og:' namespace)
:param value: property value
"""
content = [custom_meta('property', 'og:%s' % name, value)]
if name in settings.OG_SECURE_URL_ITEMS and value.startswith('https'):
name = '%s:secure_url' % name
return custom_meta('property', 'og:%s' % name, value)
content.append(custom_meta('property', 'og:%s:secure_url' % name, value))
return '\n'.join(content)


@register.simple_tag
Expand Down
1 change: 1 addition & 0 deletions tests/test_mixin.py
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,7 @@ def test_templatetag_secure_image(self):
self.assertContains(response, '<meta property="og:image" content="http://example.com/path/to/image">')
settings.SITE_PROTOCOL = 'https'
response = self.client.get('/mixin/title/')
self.assertContains(response, '<meta property="og:image" content="https://example.com/path/to/image">')
self.assertContains(response, '<meta property="og:image:secure_url" content="https://example.com/path/to/image">')
settings.SITE_PROTOCOL = 'http'

Expand Down
1 change: 1 addition & 0 deletions tests/test_templatetags.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ def test_og_prop_secure_url(self):
for content in ('image', 'video', 'audio'):
self.assertEqual(
og_prop(content, 'https://some/{}'.format(content)),
'<meta property="og:{0}" content="https://some/{0}">\n'
'<meta property="og:{0}:secure_url" content="https://some/{0}">'.format(content),
)
self.assertEqual(
Expand Down

0 comments on commit f1b0e66

Please sign in to comment.