fix: 修復 github-issues 最新評論 獲取的url格式 bug

fix: 當標題有符號'時,disqus 和 disqusjs 無法加載的 bug
This commit is contained in:
Jerry
2021-03-30 01:31:17 +08:00
Unverified
parent 6904850044
commit 637da0702b
4 changed files with 11 additions and 14 deletions

View File

@@ -15,15 +15,13 @@ script.
}
const findTrueUrl = (array) => {
let url = ''
Promise.all(array.map(item =>
fetch(item.url).then(resp => resp.json()).then(data => {
const urlArray = data.body.match(/(https?:\/\/)?([\da-z\.-]+)\.([a-z\.]{2,6})([\/\w \.-]*)*\/?/ig)
if (data.user.login === 'utterances-bot') {
url = data.body.match(/https?\:\/\/[^\" ]+/ig).slice(-1)
return url[0]
return urlArray.pop()
} else {
url = data.body.match(/https?\:\/\/[^\" ]+/i)
return url[0]
return urlArray.shift()
}
})
)).then(res => {
@@ -104,8 +102,4 @@ script.
newestCommentInit()
document.addEventListener('pjax:complete', newestCommentInit)
})
})