From 7c107e6d47415d72ca7fd075fc8f78aaae548908 Mon Sep 17 00:00:00 2001 From: Feross Aboukhadijeh Date: Fri, 2 Mar 2018 14:29:02 -0800 Subject: simplify double if statement --- lib/server.js | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/lib/server.js b/lib/server.js index d0f5716..5b24181 100644 --- a/lib/server.js +++ b/lib/server.js @@ -54,10 +54,8 @@ function Server (torrent, opts) { // If a 'hostname' string is specified, deny requests with a 'Host' // header that does not match the origin of the torrent server to prevent // DNS rebinding attacks. - if (opts.hostname) { - if (req.headers.host !== `${opts.hostname}:${server.address().port}`) { - return false - } + if (opts.hostname && req.headers.host !== `${opts.hostname}:${server.address().port}`) { + return false } // The user allowed all origins -- cgit v1.2.3