diff options
| author | Roger Braun <roger@rogerbraun.net> | 2016-11-12 22:41:43 +0100 |
|---|---|---|
| committer | Roger Braun <roger@rogerbraun.net> | 2016-11-12 22:41:43 +0100 |
| commit | 05733b6bc92db37b8c7bbee792f40125714aa020 (patch) | |
| tree | 9ca6d461cd20e906115bc5590b1400d315cdd691 /src | |
| parent | c9ab70db8ea5163b2687adf93f6e3f414873df5d (diff) | |
Remove attachment links, as we are already showing them.
Diffstat (limited to 'src')
| -rw-r--r-- | src/modules/statuses.js | 7 | ||||
| -rw-r--r-- | src/services/status_parser/status_parser.js | 15 |
2 files changed, 17 insertions, 5 deletions
diff --git a/src/modules/statuses.js b/src/modules/statuses.js index 8ed2890f..cc5e296c 100644 --- a/src/modules/statuses.js +++ b/src/modules/statuses.js @@ -1,6 +1,7 @@ import { reduce, map, slice, last, intersectionBy, sortBy, unionBy, toInteger, groupBy, differenceBy, each, find } from 'lodash' import moment from 'moment' import apiService from '../services/api/api.service.js' +import parse from '../services/status_parser/status_parser.js' export const defaultState = { allStatuses: [], @@ -60,11 +61,7 @@ const addStatusesToTimeline = (addedStatuses, showImmediately, { statuses, visib const statusoid = status.retweeted_status || status statusoid.created_at_parsed = statusoid.created_at - - if (statusoid.parsedText === undefined) { - // statusoid.parsedText = statusParserService.parse(statusoid) - statusoid.parsedText = statusoid.text - } + statusoid.statusnet_html = parse(statusoid.statusnet_html) if (statusoid.nsfw === undefined) { const nsfwRegex = /#nsfw/i diff --git a/src/services/status_parser/status_parser.js b/src/services/status_parser/status_parser.js new file mode 100644 index 00000000..0eb3e75f --- /dev/null +++ b/src/services/status_parser/status_parser.js @@ -0,0 +1,15 @@ +import sanitize from 'sanitize-html' + +export const removeAttachmentLinks = (html) => { + return sanitize(html, { + allowedTags: false, + allowedAttributes: false, + exclusiveFilter: ({ tag, attribs: { class: klass } }) => tag === 'a' && klass.match(/attachment/) + }) +} + +export const parse = (html) => { + return removeAttachmentLinks(html) +} + +export default parse |
