File tree Expand file tree Collapse file tree 3 files changed +16
-4
lines changed Expand file tree Collapse file tree 3 files changed +16
-4
lines changed Original file line number Diff line number Diff line change 53
53
},
54
54
"dependencies" : {
55
55
"body-parser" : " ~1.18.2" ,
56
+ "cheerio" : " ^1.0.0-rc.2" ,
56
57
"compression" : " ~1.7.1" ,
57
58
"cors" : " ~2.8.4" ,
58
59
"crypto" : " ~1.0.1" ,
Original file line number Diff line number Diff line change 1
1
const sanitizeHtml = require ( 'sanitize-html' ) ;
2
- const embedToAnchor = require ( 'quill-url-embeds/dist/embed-to-anchor' ) ;
2
+ // const embedToAnchor = require('quill-url-embeds/dist/embed-to-anchor');
3
3
const _ = require ( 'lodash' ) ;
4
+ const cheerio = require ( 'cheerio' ) ;
5
+
6
+ const embedToAnchor = ( content ) => {
7
+ const $ = cheerio . load ( content ) ;
8
+ $ ( 'div[data-url-embed]' ) . each ( ( i , el ) => {
9
+ let url = el . attribs [ 'data-url-embed' ] ;
10
+ let aTag = $ ( `<a href="${ url } " target="_blank" data-url-embed="">${ url } </a>` ) ;
11
+ $ ( el ) . replaceWith ( aTag ) ;
12
+ } ) ;
13
+ return $ ( 'body' ) . html ( ) ;
14
+ } ;
4
15
5
16
function clean ( dirty ) {
6
17
// Convert embeds to a-tags
Original file line number Diff line number Diff line change @@ -103,7 +103,7 @@ module.exports = {
103
103
isVerified ( )
104
104
) ,
105
105
associateCurrentUser ( ) ,
106
- // xss({ fields: ['content', 'contentExcerpt'] }),
106
+ xss ( { fields : [ 'content' , 'contentExcerpt' ] } ) ,
107
107
createSlug ( { field : 'title' } ) ,
108
108
saveRemoteImages ( [ 'teaserImg' ] ) ,
109
109
createExcerpt ( )
@@ -117,7 +117,7 @@ module.exports = {
117
117
excludeDisabled ( ) ,
118
118
restrictToOwner ( )
119
119
) ,
120
- // xss({ fields: ['content', 'contentExcerpt'] }),
120
+ xss ( { fields : [ 'content' , 'contentExcerpt' ] } ) ,
121
121
saveRemoteImages ( [ 'teaserImg' ] ) ,
122
122
createExcerpt ( )
123
123
] ,
@@ -130,7 +130,7 @@ module.exports = {
130
130
excludeDisabled ( ) ,
131
131
restrictToOwner ( )
132
132
) ,
133
- // xss({ fields: ['content', 'contentExcerpt'] }),
133
+ xss ( { fields : [ 'content' , 'contentExcerpt' ] } ) ,
134
134
saveRemoteImages ( [ 'teaserImg' ] ) ,
135
135
createExcerpt ( )
136
136
] ,
You can’t perform that action at this time.
0 commit comments