removed ref_src and ref_url from twitter urls https://github.com/libredirect/libredirect/issues/395
This commit is contained in:
parent
b62c79adf8
commit
87d68cb662
|
@ -110,13 +110,27 @@ function redirect(url, type, initiator, disableOverride) {
|
|||
|
||||
const randomInstance = utils.getRandomInstance(instancesList)
|
||||
// https://pbs.twimg.com/profile_images/648888480974508032/66_cUYfj_400x400.jpg
|
||||
|
||||
let search = new URLSearchParams(url.search)
|
||||
|
||||
search.delete("ref_src")
|
||||
search.delete("ref_url")
|
||||
|
||||
search = search.toString()
|
||||
if (search !== "") search = `?${search}`
|
||||
|
||||
if (url.host.split(".")[0] === "pbs" || url.host.split(".")[0] === "video") {
|
||||
const [, id, format, extra] = url.search.match(/(.*)\?format=(.*)&(.*)/)
|
||||
const [, id, format, extra] = search.match(/(.*)\?format=(.*)&(.*)/)
|
||||
const query = encodeURIComponent(`${id}.${format}?${extra}`)
|
||||
return `${randomInstance}/pic${url.pathname}${query}`
|
||||
} else if (url.pathname.split("/").includes("tweets")) return `${randomInstance}${url.pathname.replace("/tweets", "")}${url.search}`
|
||||
else if (url.host == "t.co") return `${randomInstance}/t.co${url.pathname}`
|
||||
else return `${randomInstance}${url.pathname}${url.search}`
|
||||
return `${randomInstance}/pic${search}${query}`
|
||||
}
|
||||
if (url.pathname.split("/").includes("tweets")) {
|
||||
return `${randomInstance}${url.pathname.replace("/tweets", "")}${search}`
|
||||
}
|
||||
if (url.host == "t.co") {
|
||||
return `${randomInstance}/t.co${url.pathname}`
|
||||
}
|
||||
return `${randomInstance}${url.pathname}${search}`
|
||||
}
|
||||
|
||||
function reverse(url) {
|
||||
|
|
Loading…
Reference in New Issue