Skip to content
Snippets Groups Projects
Commit ee009f63 authored by lain's avatar lain
Browse files

Don't break status parsing when link class is missing.

parent 43eb9c02
No related branches found
No related tags found
No related merge requests found
......@@ -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/)
})
}
......
......@@ -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>')
})
})
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment