Merge pull request #3602 from thelounge/xpaw/ua

Pretend to be facebook and twitter bots in link prefetcher
This commit is contained in:
Pavel Djundik 2019-12-19 15:25:39 +02:00 committed by GitHub
commit 7a350ac69a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 4 additions and 1 deletions

View File

@ -319,8 +319,11 @@ function removePreview(msg, preview) {
function getRequestHeaders(headers) { function getRequestHeaders(headers) {
const formattedHeaders = { const formattedHeaders = {
// Certain websites like Amazon only add <meta> tags to known bots,
// lets pretend to be them to get the metadata
"User-Agent": "User-Agent":
"Mozilla/5.0 (compatible; The Lounge IRC Client; +https://github.com/thelounge/thelounge)", "Mozilla/5.0 (compatible; The Lounge IRC Client; +https://github.com/thelounge/thelounge)" +
" facebookexternalhit/1.1 Twitterbot/1.0",
Accept: headers.accept || "*/*", Accept: headers.accept || "*/*",
"X-Purpose": "preview", "X-Purpose": "preview",
}; };