Skip to content

Commit

Permalink
Don't render non-string value for app (#1722)
Browse files Browse the repository at this point in the history
* Don't render non-string value for app

* fix lint

* use lodash, changes from jm90m's closed commit

* remove string check
  • Loading branch information
kirkins authored and Sekhmet committed Apr 14, 2018
1 parent f3a50bf commit b721860
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions src/client/post/PostContent.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import React from 'react';
import PropTypes from 'prop-types';
import { connect } from 'react-redux';
import { push } from 'react-router-redux';
import { find, truncate } from 'lodash';
import _ from 'lodash';
import { Helmet } from 'react-helmet';
import sanitize from 'sanitize-html';
import { getHasDefaultSlider } from '../helpers/user';
Expand Down Expand Up @@ -181,11 +181,12 @@ class PostContent extends React.Component {
const postMetaData = jsonParse(content.json_metadata);
const busyHost = appUrl || 'https://busy.org';
let canonicalHost = busyHost;
if (postMetaData.app && postMetaData.app.indexOf('steemit') === 0) {

if (_.indexOf(postMetaData.app, 'steemit') === 0) {
canonicalHost = 'https://steemit.com';
}

const userVote = find(content.active_votes, { voter: user.name }) || {};
const userVote = _.find(content.active_votes, { voter: user.name }) || {};

const postState = {
isReblogged: reblogList.includes(content.id),
Expand All @@ -210,7 +211,7 @@ class PostContent extends React.Component {
const postMetaImage = postMetaData.image && postMetaData.image[0];
const htmlBody = getHtml(body, {}, 'text');
const bodyText = sanitize(htmlBody, { allowedTags: [] });
const desc = `${truncate(bodyText, { length: 143 })} by ${author}`;
const desc = `${_.truncate(bodyText, { length: 143 })} by ${author}`;
const image = postMetaImage || getAvatarURL(author) || '/images/logo.png';
const canonicalUrl = `${canonicalHost}${dropCategory(content.url)}`;
const url = `${busyHost}${dropCategory(content.url)}`;
Expand Down

0 comments on commit b721860

Please sign in to comment.