modify link qs

This commit is contained in:
Jay 2018-09-25 21:44:25 +08:00
parent e25e03c4e3
commit cf506a815d
1 changed files with 13 additions and 1 deletions

View File

@ -1,5 +1,6 @@
const request = require('request')
const cheerio = require('cheerio')
const qs = require('querystring')
/**
* @typedef lastPost
@ -96,7 +97,18 @@ const getLastPost = async (pageid = '') => {
return b.time - a.time
})
let post = posts[0]
post.link = `https://www.facebook.com/${post.link.replace(/^\//, '')}`
let larr = post.link.split('?')
let linkqs = qs.parse(larr[1])
let newqs = {}
for (let i in linkqs) {
if (/id/i.test(i)) {
newqs[i] = linkqs[i]
}
}
post.link = larr[0] + '?' + qs.stringify(newqs)
post.link = `https://www.facebook.com/${post.link.replace(/^\//, '')}`.replace(/\?$/, '')
return post
}