StatusParser: Remove unused removeAttachmentLinks.

Brings down the vendor by over 200kb
This commit is contained in:
lain 2020-06-11 18:39:19 +02:00
parent dc7489fd8b
commit 8d7d4980b9
3 changed files with 1 additions and 34 deletions

View File

@ -22,12 +22,10 @@
"cropperjs": "^1.4.3",
"diff": "^3.0.1",
"escape-html": "^1.0.3",
"karma-mocha-reporter": "^2.2.1",
"localforage": "^1.5.0",
"object-path": "^0.11.3",
"phoenix": "^1.3.0",
"portal-vue": "^2.1.4",
"sanitize-html": "^1.13.0",
"v-click-outside": "^2.1.1",
"vue": "^2.6.11",
"vue-chat-scroll": "^1.2.1",
@ -39,6 +37,7 @@
"whatwg-fetch": "^2.0.3"
},
"devDependencies": {
"karma-mocha-reporter": "^2.2.1",
"@babel/core": "^7.7.5",
"@babel/plugin-transform-runtime": "^7.7.6",
"@babel/preset-env": "^7.7.6",

View File

@ -1,17 +1,4 @@
import { filter } from 'lodash'
import sanitize from 'sanitize-html'
export const removeAttachmentLinks = (html) => {
return sanitize(html, {
allowedTags: false,
allowedAttributes: false,
exclusiveFilter: ({ tag, attribs }) => tag === 'a' && typeof attribs.class === 'string' && attribs.class.match(/attachment/)
})
}
export const parse = (html) => {
return removeAttachmentLinks(html)
}
export const muteWordHits = (status, muteWords) => {
const statusText = status.text.toLowerCase()
@ -22,5 +9,3 @@ export const muteWordHits = (status, muteWords) => {
return hits
}
export default parse

View File

@ -1,17 +0,0 @@
import { removeAttachmentLinks } from '../../../../../src/services/status_parser/status_parser.js'
const example = '<div class="status-content">@<a href="https://sealion.club/user/4" class="h-card mention" title="dewoo">dwmatiz</a> <a href="https://social.heldscal.la/file/3deb764ada10ce64a61b7a070b75dac45f86d2d5bf213bf18873da71d8714d86.png" title="https://social.heldscal.la/file/3deb764ada10ce64a61b7a070b75dac45f86d2d5bf213bf18873da71d8714d86.png" class="attachment" id="attachment-159853" rel="nofollow external">https://social.heldscal.la/attachment/159853</a></div>'
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>')
})
})