commit: ee009f63dd2f4856f8daf29d66301f67ab8f2021
parent: 43eb9c022d49047e898657bf41ee5a9d9b27fe27
Author: Roger Braun <roger@rogerbraun.net>
Date: Sun, 13 Nov 2016 00:08:03 +0100
Don't break status parsing when link class is missing.
Diffstat:
2 files changed, 7 insertions(+), 1 deletion(-)
diff --git a/src/services/status_parser/status_parser.js b/src/services/status_parser/status_parser.js
@@ -4,7 +4,7 @@ export const removeAttachmentLinks = (html) => {
return sanitize(html, {
allowedTags: false,
allowedAttributes: false,
- exclusiveFilter: ({ tag, attribs }) => tag === 'a' && attribs.class.match(/attachment/)
+ exclusiveFilter: ({ tag, attribs }) => tag === 'a' && typeof attribs.class === 'string' && attribs.class.match(/attachment/)
})
}
diff --git a/test/unit/specs/services/status_parser/status_parses.spec.js b/test/unit/specs/services/status_parser/status_parses.spec.js
@@ -4,8 +4,14 @@ import { removeAttachmentLinks } from '../../../../../src/services/status_parser
describe('statusParser.removeAttachmentLinks', () => {
const exampleWithoutAttachmentLinks = '<div class="status-content">@<a href="https://sealion.club/user/4" class="h-card mention" title="dewoo">dwmatiz</a> </div>'
+
it('removes attachment links', () => {
const parsed = removeAttachmentLinks(example)
expect(parsed).to.eql(exampleWithoutAttachmentLinks)
})
+
+ it('works when the class is empty', () => {
+ const parsed = removeAttachmentLinks('<a></a>')
+ expect(parsed).to.eql('<a></a>')
+ })
})