Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
...((query.width) ? { width: parseInt(query.width) } : {}),
...((query.height) ? { height: parseInt(query.height) } : {}),
...((query.background) ? { background: query.background } : {}),
...((query.opacity) ? { opacity: parseInt(query.opacity) } : {}),
...((query.minSize) ? { minSize: parseInt(query.minSize) } : {}),
...((query.blur) ? { blur: parseInt(query.blur) } : {}),
...((query.format && (query.format === 'webp' || query.format === 'png')) ? { format: query.format } : { format: 'jpg' }),
...((query.upscale) ? { upscale: parseInt(query.upscale) } : {}),
...((query.quality) ? { quality: parseInt(query.quality) } : ((query.blur) ? { quality: 100 } : { quality: 70 })),
alpha: (query.format === 'png'),
...((query['X-Plex-Token']) ? { "X-Plex-Token": query['X-Plex-Token'] } : {}),
url
};
// Auto select WebP if user-agent support it
const browser = parseUserAgent(useragent);
if (browser && browser.name && browser.name === 'chrome' && !query.format) {
params.format = 'webp';
}
// Generate key
params.key = md5(`${(query.url || '').split('?')[0]}|${params.width || ''}|${params.height || ''}|${params.background || ''}|${params.opacity || ''}|${params.minSize || ''}|${params.blur || ''}|${params.format || ''}|${params.upscale || ''}|${params.quality || ''}`.toLowerCase())
// Return params
return params;
}
server.get("*", (req, res) => {
// Check if browse is less than IE 11
const ua = req.headers["user-agent"];
const browser = parseUserAgent(ua);
const lang = req.query.lng
? req.query.lng
: req.headers["accept-language"];
req.data = data;
req.language = lang ? lang.split(",")[0] : "en";
if (
browser &&
browser.name === "ie" &&
parseInt(browser.version) < 11 &&
!req.url.includes("all-benefits") &&
!req.url.includes(".css")
) {
res.sendFile("fallback-pages/browser-incompatible.html", {
root: __dirname
});