twikoo-func 1.6.13 → 1.6.15
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/utils/import.js +7 -7
- package/utils/index.js +6 -4
package/package.json
CHANGED
package/utils/import.js
CHANGED
|
@@ -115,8 +115,8 @@ const fn = {
|
|
|
115
115
|
ip: '',
|
|
116
116
|
isSpam: post.isSpam[0] === 'true' || post.isDeleted[0] === 'true',
|
|
117
117
|
master: false,
|
|
118
|
-
pid: parent ? parent.$['dsq:id'] :
|
|
119
|
-
rid: root ? root.$['dsq:id'] :
|
|
118
|
+
pid: parent ? parent.$['dsq:id'] : undefined,
|
|
119
|
+
rid: root ? root.$['dsq:id'] : undefined,
|
|
120
120
|
created: new Date(post.createdAt[0]).getTime(),
|
|
121
121
|
updated: Date.now()
|
|
122
122
|
})
|
|
@@ -157,8 +157,8 @@ const fn = {
|
|
|
157
157
|
isSpam: false,
|
|
158
158
|
ua: comment.ua || '',
|
|
159
159
|
link: comment.link,
|
|
160
|
-
pid: comment.rid ? `artalk${comment.rid}` :
|
|
161
|
-
rid: comment.rid ? `artalk${comment.rid}` :
|
|
160
|
+
pid: comment.rid && comment.rid !== '0' ? `artalk${comment.rid}` : undefined,
|
|
161
|
+
rid: comment.rid && comment.rid !== '0' ? `artalk${comment.rid}` : undefined,
|
|
162
162
|
master: false,
|
|
163
163
|
comment: DOMPurify.sanitize(marked.marked(comment.content)),
|
|
164
164
|
url: getRelativeUrl(comment.page_key),
|
|
@@ -201,11 +201,11 @@ const fn = {
|
|
|
201
201
|
ip: comment.ip,
|
|
202
202
|
mail: comment.email,
|
|
203
203
|
mailMd5: md5(comment.email),
|
|
204
|
-
isSpam: comment.is_pending,
|
|
204
|
+
isSpam: comment.is_pending === 'true',
|
|
205
205
|
ua: comment.ua || '',
|
|
206
206
|
link: comment.link,
|
|
207
|
-
pid: comment.rid ? `artalk${comment.rid}` :
|
|
208
|
-
rid: comment.rid ? `artalk${comment.rid}` :
|
|
207
|
+
pid: comment.rid && comment.rid !== '0' ? `artalk${comment.rid}` : undefined,
|
|
208
|
+
rid: comment.rid && comment.rid !== '0' ? `artalk${comment.rid}` : undefined,
|
|
209
209
|
master: false,
|
|
210
210
|
comment: DOMPurify.sanitize(marked.marked(comment.content)),
|
|
211
211
|
url: getRelativeUrl(comment.page_key),
|
package/utils/index.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
const { URL } = require('url')
|
|
1
2
|
const { axios, bowser, ipToRegion, md5 } = require('./lib')
|
|
2
3
|
const { RES_CODE } = require('./constants')
|
|
3
4
|
const ipRegionSearcher = ipToRegion.create() // 初始化 IP 属地
|
|
@@ -110,11 +111,12 @@ const fn = {
|
|
|
110
111
|
return comments
|
|
111
112
|
},
|
|
112
113
|
getRelativeUrl (url) {
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
114
|
+
try {
|
|
115
|
+
return (new URL(url)).pathname
|
|
116
|
+
} catch (e) {
|
|
117
|
+
// 如果 url 已经是一个相对地址了,会报 ERR_INVALID_URL,返回原始 url 就行
|
|
118
|
+
return url
|
|
116
119
|
}
|
|
117
|
-
return url.substring(x)
|
|
118
120
|
},
|
|
119
121
|
getMailMd5 (comment) {
|
|
120
122
|
if (comment.mailMd5) {
|