open graph: Use the complete URL for open graph URLs.

Closes #12199
This commit is contained in:
Puneeth Chaganti
2019-04-29 17:32:16 +05:30
committed by Tim Abbott
parent e01d3be1ba
commit dc1571426e
3 changed files with 12 additions and 1 deletions

View File

@@ -6,7 +6,7 @@
{% endif %}
<!-- Open Graph / Facebook Meta Tags -->
<meta property="og:url" content="{{ realm_uri }}">
<meta property="og:url" content="{{ OPEN_GRAPH_URL }}">
<meta property="og:type" content="website">
<meta property="og:site_name" content="Zulip">
{% if OPEN_GRAPH_TITLE %}

View File

@@ -133,6 +133,7 @@ def zulip_default_context(request: HttpRequest) -> Dict[str, Any]:
'allow_search_engine_indexing': allow_search_engine_indexing,
}
context['OPEN_GRAPH_URL'] = '%s%s' % (realm_uri, request.path)
if realm is not None and realm.icon_source == realm.ICON_UPLOADED:
context['OPEN_GRAPH_IMAGE'] = '%s%s' % (realm_uri, realm_icon)

View File

@@ -184,3 +184,13 @@ class OpenGraphTest(ZulipTestCase):
twitter_image = bs.select_one('meta[name="twitter:image"]').get('content')
self.assertTrue(open_graph_image.endswith(realm_icon))
self.assertTrue(twitter_image.endswith(realm_icon))
def test_no_realm_api_page_og_url(self) -> None:
response = self.client_get('/api/', subdomain='')
self.assertEqual(response.status_code, 200)
decoded = response.content.decode('utf-8')
bs = BeautifulSoup(decoded, features='lxml')
open_graph_url = bs.select_one('meta[property="og:url"]').get('content')
self.assertTrue(open_graph_url.endswith('/api/'))