File tree Expand file tree Collapse file tree 5 files changed +19
-16
lines changed
Expand file tree Collapse file tree 5 files changed +19
-16
lines changed Original file line number Diff line number Diff line change 1- const he = require ( 'he ' ) ;
1+ const entities = require ( 'entities ' ) ;
22const mercury_parser = require ( '@postlight/mercury-parser' ) ;
33const cheerio = require ( 'cheerio' ) ;
44const OpenCC = require ( 'opencc' ) ;
@@ -24,14 +24,14 @@ module.exports = async (ctx, next) => {
2424 ctx . state . data . item = ctx . state . data . item || [ ] ;
2525
2626 // decode HTML entities
27- ctx . state . data . title && ( ctx . state . data . title = he . decode ( ctx . state . data . title + '' ) ) ;
28- ctx . state . data . description && ( ctx . state . data . description = he . decode ( ctx . state . data . description + '' ) ) ;
27+ ctx . state . data . title && ( ctx . state . data . title = entities . decodeXML ( ctx . state . data . title + '' ) ) ;
28+ ctx . state . data . description && ( ctx . state . data . description = entities . decodeXML ( ctx . state . data . description + '' ) ) ;
2929
3030 // sort items
3131 ctx . state . data . item = ctx . state . data . item . sort ( ( a , b ) => + new Date ( b . pubDate || 0 ) - + new Date ( a . pubDate || 0 ) ) ;
3232
33- ctx . state . data . item . forEach ( ( item ) => {
34- item . title && ( item . title = he . decode ( item . title + '' ) ) ;
33+ const handleItem = async ( item ) => {
34+ item . title && ( item . title = entities . decodeXML ( item . title + '' ) ) ;
3535
3636 // handle pubDate
3737 if ( item . pubDate ) {
@@ -111,9 +111,12 @@ module.exports = async (ctx, next) => {
111111 $ele . removeAttr ( e ) ;
112112 } ) ;
113113 } ) ;
114- item . description = he . decode ( $ ( 'body' ) . html ( ) + '' ) + ( config . suffix || '' ) ;
114+ item . description = entities . decodeXML ( $ ( 'body' ) . html ( ) + '' ) + ( config . suffix || '' ) ;
115115 }
116- } ) ;
116+ return item ;
117+ } ;
118+
119+ ctx . state . data . item = await Promise . all ( ctx . state . data . item . map ( handleItem ) ) ;
117120
118121 if ( ctx . query ) {
119122 // limit
Original file line number Diff line number Diff line change 55
66const got = require ( '@/utils/got' ) ; // get web content
77const cheerio = require ( 'cheerio' ) ; // html parser
8- const he = require ( 'he ' ) ;
8+ const entities = require ( 'entities ' ) ;
99
1010const base_url = 'https://www.aozora.gr.jp/index_pages/' ;
1111module . exports = async ( ctx ) => {
@@ -50,7 +50,7 @@ module.exports = async (ctx) => {
5050 let title = '' ;
5151 let title_sub = '' ;
5252 for ( let j = 0 ; j < title_info . length ; ++ j ) {
53- const tmp = he . decode ( $ ( title_info [ j ] ) . html ( ) ) ; // should convert from escaped to unicode
53+ const tmp = entities . decodeXML ( $ ( title_info [ j ] ) . html ( ) ) ; // should convert from escaped to unicode
5454 if ( tmp . includes ( '作品名:' ) ) {
5555 title = $ ( title_info [ j ] ) . find ( 'td:nth-child(2)' ) . text ( ) ;
5656 }
Original file line number Diff line number Diff line change 11const got = require ( '@/utils/got' ) ;
22const cache = require ( './cache' ) ;
3- const he = require ( 'he ' ) ;
3+ const entities = require ( 'entities ' ) ;
44const queryString = require ( 'query-string' ) ;
55
66module . exports = async ( ctx ) => {
@@ -25,7 +25,7 @@ module.exports = async (ctx) => {
2525 link : host ,
2626 item : data . map ( ( item ) => ( {
2727 title : item . subject ,
28- description : he . escape ( he . escape ( item . content ) ) . replace ( / \n / g, '<br>' ) ,
28+ description : entities . escape ( entities . escape ( item . content ) ) . replace ( / \n / g, '<br>' ) ,
2929 pubDate : new Date ( item . date ) . toUTCString ( ) ,
3030 link : item . web_url ,
3131 } ) ) ,
Original file line number Diff line number Diff line change 11const got = require ( '@/utils/got' ) ;
2- const he = require ( 'he ' ) ;
2+ const entities = require ( 'entities ' ) ;
33const cheerio = require ( 'cheerio' ) ;
44const date = require ( '@/utils/date' ) ;
55
@@ -34,7 +34,7 @@ module.exports = async (ctx) => {
3434 const matchs = / " ( u r l | t e m p _ u r l ) " : " ( [ ^ " ] + m p \. w e i x i n \. q q \. c o m [ ^ " ] + ) " / . exec ( response ) ;
3535 let weixinLink = '' ;
3636 if ( matchs && matchs [ 2 ] ) {
37- weixinLink = he . unescape ( unescape ( matchs [ 2 ] . replace ( / \\ u / g, '%u' ) ) ) ;
37+ weixinLink = entities . decodeXML ( unescape ( matchs [ 2 ] . replace ( / \\ u / g, '%u' ) ) ) ;
3838 }
3939
4040 const single = {
Original file line number Diff line number Diff line change 22 "name" : " rsshub" ,
33 "version" : " 1.0.0" ,
44 "description" : " Make RSS Great Again!" ,
5- "main" : " lib/pkg .js" ,
5+ "main" : " lib/workers_index .js" ,
66 "files" : [
77 " lib"
88 ],
99 "scripts" : {
1010 "start" : " node lib/index.js" ,
1111 "dev" : " cross-env NODE_ENV=dev nodemon --inspect lib/index.js" ,
12+ "profiling" : " NODE_ENV=production node --prof lib/index.js" ,
1213 "docs:dev" : " vuepress dev docs" ,
1314 "docs:build" : " vuepress build docs" ,
1415 "format" : " eslint \" **/*.js\" --fix && node docs/.format/format.js && prettier \" **/*.{js,json}\" --write" ,
4142 "@vuepress/plugin-google-analytics" : " 1.7.1" ,
4243 "@vuepress/plugin-pwa" : " 1.7.1" ,
4344 "cross-env" : " 7.0.3" ,
44- "entities" : " 2.1.0" ,
4545 "eslint" : " 7.16.0" ,
4646 "eslint-config-prettier" : " 7.1.0" ,
4747 "eslint-plugin-prettier" : " 3.3.0" ,
7878 "dayjs" : " 1.9.7" ,
7979 "dotenv" : " 8.2.0" ,
8080 "emailjs-imap-client" : " 3.1.0" ,
81+ "entities" : " 2.1.0" ,
8182 "etag" : " 1.8.1" ,
8283 "fanfou-sdk" : " 4.2.0" ,
8384 "git-rev-sync" : " 3.0.1" ,
8485 "googleapis" : " 66.0.0" ,
8586 "got" : " 11.8.1" ,
86- "he" : " 1.2.0" ,
8787 "https-proxy-agent" : " 5.0.0" ,
8888 "iconv-lite" : " 0.6.2" ,
8989 "instagram-private-api" : " 1.43.3" ,
You can’t perform that action at this time.
0 commit comments