fix some anti pattern stuff

This commit is contained in:
Mystikfluu
2023-02-10 19:24:05 +01:00
parent 0a46eeee9f
commit 3254d01581
21 changed files with 130 additions and 151 deletions
+2 -2
View File
@@ -8,13 +8,13 @@ import {mkdir} from "fs"
* @return {undefined} see: callback
*/
function ensureExists(path, mask, cb) {
if (typeof mask == 'function') { // Allow the `mask` parameter to be optional
if (typeof mask === 'function') { // Allow the `mask` parameter to be optional
cb = mask;
mask = 0o744;
}
mkdir(path, mask, function (err) {
if (err) {
if (err.code == 'EEXIST')
if (err.code === 'EEXIST')
cb(null); // Ignore the error if the folder already exists
else
cb(err); // Something else went wrong
+1 -1
View File
@@ -7,7 +7,7 @@ const config = JSON.parse(fs.readFileSync("server_config.json"));
*/
function getIP(req) {
let ip = req.socket.remoteAddress;
if (req.headers[config.preferred_ip_header] != undefined && ip == config.only_prefer_when_ip)
if (req.headers[config.preferred_ip_header] !== undefined && ip === config.only_prefer_when_ip)
ip = req.headers[config.preferred_ip_header];
return ip;
}