diff --git a/app/components/post_attachment_opengraph/__snapshots__/post_attachment_opengraph.test.js.snap b/app/components/post_attachment_opengraph/__snapshots__/post_attachment_opengraph.test.js.snap
index 511342b6e..296098fa8 100644
--- a/app/components/post_attachment_opengraph/__snapshots__/post_attachment_opengraph.test.js.snap
+++ b/app/components/post_attachment_opengraph/__snapshots__/post_attachment_opengraph.test.js.snap
@@ -129,6 +129,59 @@ exports[`PostAttachmentOpenGraph should match snapshot, without site_name 1`] =
`;
+exports[`PostAttachmentOpenGraph should match snapshot, without title and url 1`] = `
+
+
+
+
+ https://mattermost.com/
+
+
+
+
+`;
+
exports[`PostAttachmentOpenGraph should match state and snapshot, on renderDescription 1`] = `null`;
exports[`PostAttachmentOpenGraph should match state and snapshot, on renderDescription 2`] = `
diff --git a/app/components/post_attachment_opengraph/post_attachment_opengraph.js b/app/components/post_attachment_opengraph/post_attachment_opengraph.js
index e232b879d..de55813b5 100644
--- a/app/components/post_attachment_opengraph/post_attachment_opengraph.js
+++ b/app/components/post_attachment_opengraph/post_attachment_opengraph.js
@@ -226,7 +226,12 @@ export default class PostAttachmentOpenGraph extends PureComponent {
}
render() {
- const {isReplyPost, openGraphData, theme} = this.props;
+ const {
+ isReplyPost,
+ link,
+ openGraphData,
+ theme,
+ } = this.props;
if (!openGraphData) {
return null;
@@ -234,9 +239,9 @@ export default class PostAttachmentOpenGraph extends PureComponent {
const style = getStyleSheet(theme);
- let siteTitle;
+ let siteName;
if (openGraphData.site_name) {
- siteTitle = (
+ siteName = (
- {siteTitle}
+ const title = openGraphData.title || openGraphData.url || link;
+ let siteTitle;
+ if (title) {
+ siteTitle = (
- {openGraphData.title || openGraphData.url}
+ {title}
+ );
+ }
+
+ return (
+
+ {siteName}
+ {siteTitle}
{this.renderDescription()}
{this.renderImage()}
diff --git a/app/components/post_attachment_opengraph/post_attachment_opengraph.test.js b/app/components/post_attachment_opengraph/post_attachment_opengraph.test.js
index 470897d11..a436b873c 100644
--- a/app/components/post_attachment_opengraph/post_attachment_opengraph.test.js
+++ b/app/components/post_attachment_opengraph/post_attachment_opengraph.test.js
@@ -58,6 +58,16 @@ describe('PostAttachmentOpenGraph', () => {
expect(wrapper.getElement()).toMatchSnapshot();
});
+ test('should match snapshot, without title and url', () => {
+ const wrapper = shallow(
+
+ );
+ expect(wrapper.getElement()).toMatchSnapshot();
+ });
+
test('should match state and snapshot, on renderImage', () => {
const wrapper = shallow(